protocol

package
v0.0.0-...-1800484 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// OpHandshake handshake
	OpHandshake = int32(0)
	// OpHandshakeReply handshake reply
	OpHandshakeReply = int32(1)

	// OpHeartbeat heartbeat
	OpHeartbeat = int32(2)
	// OpHeartbeatReply heartbeat reply
	OpHeartbeatReply = int32(3)

	// OpSendMsg send message.
	OpSendMsg = int32(4)
	// OpSendMsgReply  send message reply
	OpSendMsgReply = int32(5)

	// OpDisconnectReply disconnect reply
	OpDisconnectReply = int32(6)

	// OpAuth auth connnect
	OpAuth = int32(7)
	// OpAuthReply auth connect reply
	OpAuthReply = int32(8)

	// OpRaw raw message
	OpRaw = int32(9)

	// OpProtoReady proto ready
	OpProtoReady = int32(10)
	// OpProtoFinish proto finish
	OpProtoFinish = int32(11)

	// OpChangeRoom change room
	OpChangeRoom = int32(12)
	// OpChangeRoomReply change room reply
	OpChangeRoomReply = int32(13)

	// OpSub subscribe operation
	OpSub = int32(14)
	// OpSubReply subscribe operation
	OpSubReply = int32(15)

	// OpUnsub unsubscribe operation
	OpUnsub = int32(16)
	// OpUnsubReply unsubscribe operation reply
	OpUnsubReply = int32(17)
)
View Source
const (
	// MaxBodySize max proto body size
	MaxBodySize = int32(1 << 12)
)

Variables

View Source
var (
	// ErrProtoPackLen proto packet len error
	ErrProtoPackLen = errors.New("default server codec pack length error")
	// ErrProtoHeaderLen proto header len error
	ErrProtoHeaderLen = errors.New("default server codec header length error")
)
View Source
var (
	// ProtoReady proto ready
	ProtoReady = &Proto{Op: OpProtoReady}
	// ProtoFinish proto finish
	ProtoFinish = &Proto{Op: OpProtoFinish}
)

Functions

This section is empty.

Types

type Proto

type Proto struct {
	Ver                  int32    `protobuf:"varint,1,opt,name=ver,proto3" json:"ver,omitempty"`
	Op                   int32    `protobuf:"varint,2,opt,name=op,proto3" json:"op,omitempty"`
	Seq                  int32    `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"`
	Body                 []byte   `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

v1.0.0 protocol

func (*Proto) Descriptor

func (*Proto) Descriptor() ([]byte, []int)

func (*Proto) GetBody

func (m *Proto) GetBody() []byte

func (*Proto) GetOp

func (m *Proto) GetOp() int32

func (*Proto) GetSeq

func (m *Proto) GetSeq() int32

func (*Proto) GetVer

func (m *Proto) GetVer() int32

func (*Proto) ProtoMessage

func (*Proto) ProtoMessage()

func (*Proto) ReadTCP

func (p *Proto) ReadTCP(rr *bufio.Reader) (err error)

ReadTCP read a proto from TCP reader.

func (*Proto) ReadWebsocket

func (p *Proto) ReadWebsocket(ws *websocket.Conn) (err error)

ReadWebsocket read a proto from websocket connection.

func (*Proto) Reset

func (m *Proto) Reset()

func (*Proto) String

func (m *Proto) String() string

func (*Proto) WriteTCP

func (p *Proto) WriteTCP(wr *bufio.Writer) (err error)

WriteTCP write a proto to TCP writer.

func (*Proto) WriteTCPHeart

func (p *Proto) WriteTCPHeart(wr *bufio.Writer, online int32) (err error)

WriteTCPHeart write TCP heartbeat with room online.

func (*Proto) WriteTo

func (p *Proto) WriteTo(b *bytes.Writer)

WriteTo write a proto to bytes writer.

func (*Proto) WriteWebsocket

func (p *Proto) WriteWebsocket(ws *websocket.Conn) (err error)

WriteWebsocket write a proto to websocket connection.

func (*Proto) WriteWebsocketHeart

func (p *Proto) WriteWebsocketHeart(wr *websocket.Conn, online int32) (err error)

WriteWebsocketHeart write websocket heartbeat with room online.

func (*Proto) XXX_DiscardUnknown

func (m *Proto) XXX_DiscardUnknown()

func (*Proto) XXX_Marshal

func (m *Proto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Proto) XXX_Merge

func (m *Proto) XXX_Merge(src proto.Message)

func (*Proto) XXX_Size

func (m *Proto) XXX_Size() int

func (*Proto) XXX_Unmarshal

func (m *Proto) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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