proto

package
v0.0.0-...-d050cfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TCP_MAX_PACKET_SIZE int = 16 * 1024
View Source
const UDP_MAX_PACKET_SIZE int = 5 * 1024

Variables

View Source
var (
	APPLICATION_SEND           int16 = 1
	APPLICATION_TRACE_SEND     int16 = 2
	APPLICATION_TRACE_SEND_ACK int16 = 3

	APPLICATION_REQUEST  int16 = 5
	APPLICATION_RESPONSE int16 = 6

	APPLICATION_STREAM_CREATE         int16 = 10
	APPLICATION_STREAM_CREATE_SUCCESS int16 = 12
	APPLICATION_STREAM_CREATE_FAIL    int16 = 14

	APPLICATION_STREAM_CLOSE int16 = 15

	APPLICATION_STREAM_PING int16 = 17
	APPLICATION_STREAM_PONG int16 = 18

	APPLICATION_STREAM_RESPONSE int16 = 20

	CONTROL_CLIENT_CLOSE int16 = 100
	CONTROL_SERVER_CLOSE int16 = 110

	// control packet
	CONTROL_HANDSHAKE          int16 = 150
	CONTROL_HANDSHAKE_RESPONSE int16 = 151

	// keep stay because of performance in case of ping and pong. others removed.
	// CONTROL_PING will be deprecated. caused : Two payload types are used in one control packet.
	// since 1.7.0, use CONTROL_PING_SIMPLE, CONTROL_PING_PAYLOAD
	//@Deprecated
	CONTROL_PING int16 = 200
	CONTROL_PONG int16 = 201

	CONTROL_PING_SIMPLE  int16 = 210
	CONTROL_PING_PAYLOAD int16 = 211

	UNKNOWN int16 = 500

	PACKET_TYPE_SIZE int16 = 2
)

packetType

View Source
var (
	CODE     string = "code"
	SUB_CODE string = "subCode"
	CLUSTER  string = "cluster"
)
View Source
var (
	HANDSHAKE_SUCCESS               = &HandshakeResponseCode{0, 0, "Success."}
	HANDSHAKE_SIMPLEX_COMMUNICATION = &HandshakeResponseCode{0, 1, "Simplex Connection successfully established."}
	HANDSHAKE_DUPLEX_COMMUNICATION  = &HandshakeResponseCode{0, 2, "Duplex Connection successfully established."}

	HANDSHAKE_ALREADY_KNOWN                 = &HandshakeResponseCode{1, 0, "Already Known."}
	HANDSHAKE_ALREADY_SIMPLEX_COMMUNICATION = &HandshakeResponseCode{1, 1, "Already Simplex Connection established."}
	HANDSHAKE_ALREADY_DUPLEX_COMMUNICATION  = &HandshakeResponseCode{1, 2, "Already Duplex Connection established."}

	HANDSHAKE_PROPERTY_ERROR = &HandshakeResponseCode{2, 0, "Property error."}

	HANDSHAKE_PROTOCOL_ERROR = &HandshakeResponseCode{3, 0, "Illegal protocol error."}
	HANDSHAKE_UNKNOWN_ERROR  = &HandshakeResponseCode{4, 0, "Unknown Error."}
	HANDSHAKE_UNKNOWN_CODE   = &HandshakeResponseCode{-1, -1, "Unknown Code."}
)

Functions

func DealRequestResponse

func DealRequestResponse(message Packet) *trace.TResult_

Types

type ApplicationRequest

type ApplicationRequest struct {
	Type      int16
	RequestID int
	Length    int
	Payload   []byte
}

APPLICATION_REQUEST ApplicationSend ...

func NewApplicationRequest

func NewApplicationRequest() *ApplicationRequest

NewApplicationRequest ....

func (*ApplicationRequest) Decode

func (a *ApplicationRequest) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationRequest) Encode

func (a *ApplicationRequest) Encode() ([]byte, error)

Encode ...

func (*ApplicationRequest) GetPacketType

func (a *ApplicationRequest) GetPacketType() int16

GetPacketType ...

func (*ApplicationRequest) GetPayload

func (a *ApplicationRequest) GetPayload() []byte

GetPayload ...

func (*ApplicationRequest) GetRequestID

func (a *ApplicationRequest) GetRequestID() int

GetRequestID ...

type ApplicationResponse

type ApplicationResponse struct {
	Type      int16
	RequestID int
	Length    int
	Payload   []byte
}

ApplicationResponse ...

func NewApplicationResponse

func NewApplicationResponse() *ApplicationResponse

func (*ApplicationResponse) Decode

func (a *ApplicationResponse) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationResponse) Encode

func (a *ApplicationResponse) Encode() ([]byte, error)

Encode ...

func (*ApplicationResponse) GetPacketType

func (a *ApplicationResponse) GetPacketType() int16

GetPacketType ...

func (*ApplicationResponse) GetPayload

func (a *ApplicationResponse) GetPayload() []byte

GetPayload ...

func (*ApplicationResponse) GetRequestID

func (a *ApplicationResponse) GetRequestID() int

GetRequestID ...

type ApplicationSend

type ApplicationSend struct {
	Type    int16
	Length  int
	Payload []byte
}

APPLICATION_SEND ApplicationSend ...

func NewApplicationSend

func NewApplicationSend() *ApplicationSend

func (*ApplicationSend) Decode

func (a *ApplicationSend) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationSend) Encode

func (a *ApplicationSend) Encode() ([]byte, error)

Encode ...

func (*ApplicationSend) GetPacketType

func (a *ApplicationSend) GetPacketType() int16

GetPacketType ...

func (*ApplicationSend) GetPayload

func (a *ApplicationSend) GetPayload() []byte

GetPayload ...

func (*ApplicationSend) GetRequestID

func (a *ApplicationSend) GetRequestID() int

GetRequestID ...

type ApplicationStreamClose

type ApplicationStreamClose struct {
	Type      int16
	ChannelID int
	Code      int16
}

ApplicationStreamClose ...

func NewApplicationStreamClose

func NewApplicationStreamClose() *ApplicationStreamClose

NewApplicationStreamClose ...

func (*ApplicationStreamClose) Decode

func (a *ApplicationStreamClose) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamClose) Encode

func (a *ApplicationStreamClose) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamClose) GetPacketType

func (a *ApplicationStreamClose) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamClose) GetPayload

func (a *ApplicationStreamClose) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamClose) GetRequestID

func (a *ApplicationStreamClose) GetRequestID() int

GetRequestID ...

type ApplicationStreamCreate

type ApplicationStreamCreate struct {
	Type      int16
	ChannelID int
	Length    int
	Payload   []byte
}

ApplicationStreamCreate ...

func NewApplicationStreamCreate

func NewApplicationStreamCreate() *ApplicationStreamCreate

NewApplicationStreamCreate ...

func (*ApplicationStreamCreate) Decode

func (a *ApplicationStreamCreate) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamCreate) Encode

func (a *ApplicationStreamCreate) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamCreate) GetPacketType

func (a *ApplicationStreamCreate) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamCreate) GetPayload

func (a *ApplicationStreamCreate) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamCreate) GetRequestID

func (a *ApplicationStreamCreate) GetRequestID() int

GetRequestID ...

type ApplicationStreamCreateFail

type ApplicationStreamCreateFail struct {
	Type      int16
	ChannelID int
	Code      int16
}

ApplicationStreamCreateFail ...

func NewApplicationStreamCreateFail

func NewApplicationStreamCreateFail() *ApplicationStreamCreateFail

NewApplicationStreamCreateFail ...

func (*ApplicationStreamCreateFail) Decode

func (a *ApplicationStreamCreateFail) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamCreateFail) Encode

func (a *ApplicationStreamCreateFail) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamCreateFail) GetPacketType

func (a *ApplicationStreamCreateFail) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamCreateFail) GetPayload

func (a *ApplicationStreamCreateFail) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamCreateFail) GetRequestID

func (a *ApplicationStreamCreateFail) GetRequestID() int

GetRequestID ...

type ApplicationStreamCreateSuccess

type ApplicationStreamCreateSuccess struct {
	Type      int16
	ChannelID int
}

ApplicationStreamCreateSuccess ...

func NewApplicationStreamCreateSuccess

func NewApplicationStreamCreateSuccess() *ApplicationStreamCreateSuccess

NewApplicationStreamCreateSuccess ...

func (*ApplicationStreamCreateSuccess) Decode

func (a *ApplicationStreamCreateSuccess) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamCreateSuccess) Encode

func (a *ApplicationStreamCreateSuccess) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamCreateSuccess) GetPacketType

func (a *ApplicationStreamCreateSuccess) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamCreateSuccess) GetPayload

func (a *ApplicationStreamCreateSuccess) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamCreateSuccess) GetRequestID

func (a *ApplicationStreamCreateSuccess) GetRequestID() int

GetRequestID ...

type ApplicationStreamPing

type ApplicationStreamPing struct {
	Type      int16
	ChannelID int
	RequestID int
}

ApplicationStreamPing ...

func NewApplicationStreamPing

func NewApplicationStreamPing() *ApplicationStreamPing

NewApplicationStreamPing ...

func (*ApplicationStreamPing) Decode

func (a *ApplicationStreamPing) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamPing) Encode

func (a *ApplicationStreamPing) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamPing) GetPacketType

func (a *ApplicationStreamPing) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamPing) GetPayload

func (a *ApplicationStreamPing) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamPing) GetRequestID

func (a *ApplicationStreamPing) GetRequestID() int

GetRequestID ...

type ApplicationStreamPong

type ApplicationStreamPong struct {
	Type      int16
	ChannelID int
	RequestID int
}

ApplicationStreamPong ...

func NewApplicationStreamPong

func NewApplicationStreamPong() *ApplicationStreamPong

NewApplicationStreamPong ...

func (*ApplicationStreamPong) Decode

func (a *ApplicationStreamPong) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamPong) Encode

func (a *ApplicationStreamPong) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamPong) GetPacketType

func (a *ApplicationStreamPong) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamPong) GetPayload

func (a *ApplicationStreamPong) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamPong) GetRequestID

func (a *ApplicationStreamPong) GetRequestID() int

GetRequestID ...

type ApplicationStreamResponse

type ApplicationStreamResponse struct {
	Type      int16
	ChannelID int
	Length    int
	Payload   []byte
}

ApplicationStreamResponse ...

func NewApplicationStreamResponse

func NewApplicationStreamResponse() *ApplicationStreamResponse

NewApplicationStreamResponse ...

func (*ApplicationStreamResponse) Decode

func (a *ApplicationStreamResponse) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ApplicationStreamResponse) Encode

func (a *ApplicationStreamResponse) Encode() ([]byte, error)

Encode ...

func (*ApplicationStreamResponse) GetPacketType

func (a *ApplicationStreamResponse) GetPacketType() int16

GetPacketType ...

func (*ApplicationStreamResponse) GetPayload

func (a *ApplicationStreamResponse) GetPayload() []byte

GetPayload ...

func (*ApplicationStreamResponse) GetRequestID

func (a *ApplicationStreamResponse) GetRequestID() int

GetRequestID ...

type ControlClientClose

type ControlClientClose struct {
	Type    int16
	Length  int
	Payload []byte
}

ControlClientClose ...

func NewControlClientClose

func NewControlClientClose() *ControlClientClose

NewControlClientClose ...

func (*ControlClientClose) Decode

func (c *ControlClientClose) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ControlClientClose) Encode

func (c *ControlClientClose) Encode() ([]byte, error)

Encode ...

func (*ControlClientClose) GetPacketType

func (c *ControlClientClose) GetPacketType() int16

GetPacketType ...

func (*ControlClientClose) GetPayload

func (c *ControlClientClose) GetPayload() []byte

GetPayload ...

func (*ControlClientClose) GetRequestID

func (c *ControlClientClose) GetRequestID() int

GetRequestID ...

type ControlHandShake

type ControlHandShake struct {
	Type      int16
	RequestID int
	Length    int
	Payload   []byte
}

ControlHandShake

func NewControlHandShake

func NewControlHandShake() *ControlHandShake

NewControlHandShake ...

func (*ControlHandShake) Decode

func (c *ControlHandShake) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ControlHandShake) Encode

func (c *ControlHandShake) Encode() ([]byte, error)

Encode ...

func (*ControlHandShake) GetPacketType

func (c *ControlHandShake) GetPacketType() int16

GetPacketType ...

func (*ControlHandShake) GetPayload

func (c *ControlHandShake) GetPayload() []byte

GetPayload ...

func (*ControlHandShake) GetRequestID

func (c *ControlHandShake) GetRequestID() int

GetRequestID ...

type ControlHandShakeResponse

type ControlHandShakeResponse struct {
	Type      int16
	RequestID int
	Length    int
	Payload   []byte
}

ControlHandShake

func NewControlHandShakeResponse

func NewControlHandShakeResponse() *ControlHandShakeResponse

NewControlHandShake ...

func (*ControlHandShakeResponse) Decode

func (c *ControlHandShakeResponse) Decode(conn net.Conn, reader io.Reader) error

Decode ...

func (*ControlHandShakeResponse) Encode

func (c *ControlHandShakeResponse) Encode() ([]byte, error)

Encode ...

func (*ControlHandShakeResponse) GetPacketType

func (c *ControlHandShakeResponse) GetPacketType() int16

GetPacketType ...

func (*ControlHandShakeResponse) GetPayload

func (c *ControlHandShakeResponse) GetPayload() []byte

GetPayload ...

func (*ControlHandShakeResponse) GetRequestID

func (c *ControlHandShakeResponse) GetRequestID() int

GetRequestID ...

type ControlPing

type ControlPing struct {
	Type         int16
	PingID       int
	StateVersion byte
	// contains filtered or unexported fields
}

CONTROL_PING ControlPing ...

func NewControlPing

func NewControlPing() *ControlPing

func (*ControlPing) Decode

func (c *ControlPing) Decode(conn net.Conn, reader io.Reader) error

func (*ControlPing) Encode

func (c *ControlPing) Encode() ([]byte, error)

Encode ...

func (*ControlPing) GetPacketType

func (c *ControlPing) GetPacketType() int16

GetPacketType ...

func (*ControlPing) GetPayload

func (c *ControlPing) GetPayload() []byte

GetPayload ...

func (*ControlPing) GetRequestID

func (c *ControlPing) GetRequestID() int

GetRequestID ...

type ControlPingPayload

type ControlPingPayload struct {
	Type         int16
	PingID       int
	StateVersion byte
	// contains filtered or unexported fields
}

CONTROL_PING_PAYLOAD ControlPingPayload ...

func NewControlPingPayload

func NewControlPingPayload() *ControlPingPayload

func (*ControlPingPayload) Decode

func (c *ControlPingPayload) Decode(conn net.Conn, reader io.Reader) error

func (*ControlPingPayload) Encode

func (c *ControlPingPayload) Encode() ([]byte, error)

Encode ...

func (*ControlPingPayload) GetPacketType

func (c *ControlPingPayload) GetPacketType() int16

GetPacketType ...

func (*ControlPingPayload) GetPayload

func (c *ControlPingPayload) GetPayload() []byte

GetPayload ...

func (*ControlPingPayload) GetRequestID

func (c *ControlPingPayload) GetRequestID() int

GetRequestID ...

type ControlPong

type ControlPong struct {
	Type int16
}

CONTROL_PONG ControlPong ...

func NewControlPong

func NewControlPong() *ControlPong

func (*ControlPong) Decode

func (c *ControlPong) Decode(conn net.Conn, reader io.Reader) error

func (*ControlPong) Encode

func (c *ControlPong) Encode() ([]byte, error)

Encode ...

func (*ControlPong) GetPacketType

func (c *ControlPong) GetPacketType() int16

GetPacketType ...

func (*ControlPong) GetPayload

func (c *ControlPong) GetPayload() []byte

GetPayload ...

func (*ControlPong) GetRequestID

func (c *ControlPong) GetRequestID() int

GetRequestID ...

type HandshakeResponseCode

type HandshakeResponseCode struct {
	Code        int
	SubCode     int
	CodeMessage string
}

type Packet

type Packet interface {
	Decode(conn net.Conn, reader io.Reader) error
	Encode() ([]byte, error)
	GetPacketType() int16
	GetPayload() []byte
	GetRequestID() int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL