protocol

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBodySize max proto body size
	MaxBodySize = int32(1 << 14)
)

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: int32(Op_ProtoReady)}
	// ProtoFinish proto finish
	ProtoFinish = &Proto{Op: int32(Op_ProtoFinish)}
)
View Source
var (
	Op_name = map[int32]string{
		0:  "Undefined",
		1:  "Auth",
		2:  "AuthReply",
		3:  "Heartbeat",
		4:  "HeartbeatReply",
		5:  "Disconnect",
		6:  "DisconnectReply",
		7:  "SendMsg",
		8:  "SendMsgReply",
		9:  "ReceiveMsg",
		10: "ReceiveMsgReply",
		11: "ProtoReady",
		12: "ProtoFinish",
		13: "Raw",
		14: "SyncMsgReq",
		15: "SyncMsgReply",
		16: "RePush",
	}
	Op_value = map[string]int32{
		"Undefined":       0,
		"Auth":            1,
		"AuthReply":       2,
		"Heartbeat":       3,
		"HeartbeatReply":  4,
		"Disconnect":      5,
		"DisconnectReply": 6,
		"SendMsg":         7,
		"SendMsgReply":    8,
		"ReceiveMsg":      9,
		"ReceiveMsgReply": 10,
		"ProtoReady":      11,
		"ProtoFinish":     12,
		"Raw":             13,
		"SyncMsgReq":      14,
		"SyncMsgReply":    15,
		"RePush":          16,
	}
)

Enum value maps for Op.

View Source
var File_protocol_protocol_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Op

type Op int32
const (
	Op_Undefined       Op = 0
	Op_Auth            Op = 1
	Op_AuthReply       Op = 2
	Op_Heartbeat       Op = 3
	Op_HeartbeatReply  Op = 4
	Op_Disconnect      Op = 5
	Op_DisconnectReply Op = 6
	Op_SendMsg         Op = 7
	Op_SendMsgReply    Op = 8 //客户端回复消息已收到
	Op_ReceiveMsg      Op = 9
	Op_ReceiveMsgReply Op = 10
	Op_ProtoReady      Op = 11
	Op_ProtoFinish     Op = 12
	Op_Raw             Op = 13
	Op_SyncMsgReq      Op = 14
	Op_SyncMsgReply    Op = 15
	Op_RePush          Op = 16
)

func (Op) Descriptor

func (Op) Descriptor() protoreflect.EnumDescriptor

func (Op) Enum

func (x Op) Enum() *Op

func (Op) EnumDescriptor deprecated

func (Op) EnumDescriptor() ([]byte, []int)

Deprecated: Use Op.Descriptor instead.

func (Op) Number

func (x Op) Number() protoreflect.EnumNumber

func (Op) String

func (x Op) String() string

func (Op) Type

func (Op) Type() protoreflect.EnumType

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"`
	Ack  int32  `protobuf:"varint,4,opt,name=ack,proto3" json:"ack,omitempty"`
	Body []byte `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

func (*Proto) Descriptor deprecated

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

Deprecated: Use Proto.ProtoReflect.Descriptor instead.

func (*Proto) GetAck

func (x *Proto) GetAck() int32

func (*Proto) GetBody

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

func (*Proto) GetOp

func (x *Proto) GetOp() int32

func (*Proto) GetSeq

func (x *Proto) GetSeq() int32

func (*Proto) GetVer

func (x *Proto) GetVer() int32

func (*Proto) ProtoMessage

func (*Proto) ProtoMessage()

func (*Proto) ProtoReflect

func (x *Proto) ProtoReflect() protoreflect.Message

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) ReadWebsocket2

func (p *Proto) ReadWebsocket2(ws *gws.Conn) (err error)

ReadWebsocket read a proto from websocket connection.

func (*Proto) Reset

func (x *Proto) Reset()

func (*Proto) String

func (x *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) WriteWebsocket2

func (p *Proto) WriteWebsocket2(ws *gws.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.

Jump to

Keyboard shortcuts

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