protocol

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Channel uint32 = iota
	Room
	Broadcast
)
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 (
	None uint32 = iota

	Handshake
	HandshakeReply

	Request
	Ack
	MAck
	Notify
	AckNotify

	Heartbeat
	HeartbeatReply

	Auth
	AuthReply

	Ready
	Finish

	ChangeRoom
	ChangeRoomReply

	JoinRoom
	JoinRoomReply

	LeaveRoom
	LeaveRoomReply

	Sub
	SubReply

	Unsub
	UnsubReply

	Chat
	ChatReply

	GroupChat
)
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 = &Message{Operation: Ready}
	// ProtoFinish proto finish
	ProtoFinish = &Message{Operation: Finish}
)
View Source
var File_api_protocol_base_proto protoreflect.FileDescriptor
View Source
var File_api_protocol_message_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type BaseReply

type BaseReply struct {
	StatusCode    int32  `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` //状态码: 0-成功, 其他值-失败
	StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"`
	ServiceTime   int64  `protobuf:"varint,3,opt,name=service_time,json=serviceTime,proto3" json:"service_time,omitempty"`
	// contains filtered or unexported fields
}

func (*BaseReply) Descriptor deprecated

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

Deprecated: Use BaseReply.ProtoReflect.Descriptor instead.

func (*BaseReply) GetServiceTime

func (x *BaseReply) GetServiceTime() int64

func (*BaseReply) GetStatusCode

func (x *BaseReply) GetStatusCode() int32

func (*BaseReply) GetStatusMessage

func (x *BaseReply) GetStatusMessage() string

func (*BaseReply) ProtoMessage

func (*BaseReply) ProtoMessage()

func (*BaseReply) ProtoReflect

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

func (*BaseReply) Reset

func (x *BaseReply) Reset()

func (*BaseReply) String

func (x *BaseReply) String() string

type ChatReceiveMessage added in v0.0.2

type ChatReceiveMessage struct {
	ConversationId uint64 `protobuf:"varint,1,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"`
	From           uint64 `protobuf:"varint,2,opt,name=from,proto3" json:"from,omitempty"`
	Content        []byte `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatReceiveMessage) Descriptor deprecated added in v0.0.2

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

Deprecated: Use ChatReceiveMessage.ProtoReflect.Descriptor instead.

func (*ChatReceiveMessage) GetContent added in v0.0.2

func (x *ChatReceiveMessage) GetContent() []byte

func (*ChatReceiveMessage) GetConversationId added in v0.0.2

func (x *ChatReceiveMessage) GetConversationId() uint64

func (*ChatReceiveMessage) GetFrom added in v0.0.2

func (x *ChatReceiveMessage) GetFrom() uint64

func (*ChatReceiveMessage) ProtoMessage added in v0.0.2

func (*ChatReceiveMessage) ProtoMessage()

func (*ChatReceiveMessage) ProtoReflect added in v0.0.2

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

func (*ChatReceiveMessage) Reset added in v0.0.2

func (x *ChatReceiveMessage) Reset()

func (*ChatReceiveMessage) String added in v0.0.2

func (x *ChatReceiveMessage) String() string

type ChatSendMessage added in v0.0.2

type ChatSendMessage struct {
	ConversationId uint64 `protobuf:"varint,1,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"`
	From           uint64 `protobuf:"varint,2,opt,name=from,proto3" json:"from,omitempty"`
	To             uint64 `protobuf:"varint,3,opt,name=to,proto3" json:"to,omitempty"`
	Content        []byte `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatSendMessage) Descriptor deprecated added in v0.0.2

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

Deprecated: Use ChatSendMessage.ProtoReflect.Descriptor instead.

func (*ChatSendMessage) GetContent added in v0.0.2

func (x *ChatSendMessage) GetContent() []byte

func (*ChatSendMessage) GetConversationId added in v0.0.2

func (x *ChatSendMessage) GetConversationId() uint64

func (*ChatSendMessage) GetFrom added in v0.0.2

func (x *ChatSendMessage) GetFrom() uint64

func (*ChatSendMessage) GetTo added in v0.0.2

func (x *ChatSendMessage) GetTo() uint64

func (*ChatSendMessage) ProtoMessage added in v0.0.2

func (*ChatSendMessage) ProtoMessage()

func (*ChatSendMessage) ProtoReflect added in v0.0.2

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

func (*ChatSendMessage) Reset added in v0.0.2

func (x *ChatSendMessage) Reset()

func (*ChatSendMessage) String added in v0.0.2

func (x *ChatSendMessage) String() string

type DispatcherMessage added in v0.0.2

type DispatcherMessage struct {
	Receivers []uint64 `protobuf:"varint,1,rep,packed,name=receivers,proto3" json:"receivers,omitempty"`
	Operation uint32   `protobuf:"varint,2,opt,name=operation,proto3" json:"operation,omitempty"` //区分消息类型
	Sequence  uint32   `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
	Data      []byte   `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` //消息内容
	// contains filtered or unexported fields
}

func (*DispatcherMessage) Descriptor deprecated added in v0.0.2

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

Deprecated: Use DispatcherMessage.ProtoReflect.Descriptor instead.

func (*DispatcherMessage) GetData added in v0.0.2

func (x *DispatcherMessage) GetData() []byte

func (*DispatcherMessage) GetOperation added in v0.0.2

func (x *DispatcherMessage) GetOperation() uint32

func (*DispatcherMessage) GetReceivers added in v0.0.2

func (x *DispatcherMessage) GetReceivers() []uint64

func (*DispatcherMessage) GetSequence added in v0.0.2

func (x *DispatcherMessage) GetSequence() uint32

func (*DispatcherMessage) ProtoMessage added in v0.0.2

func (*DispatcherMessage) ProtoMessage()

func (*DispatcherMessage) ProtoReflect added in v0.0.2

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

func (*DispatcherMessage) Reset added in v0.0.2

func (x *DispatcherMessage) Reset()

func (*DispatcherMessage) String added in v0.0.2

func (x *DispatcherMessage) String() string

type GroupChatMessage

type GroupChatMessage struct {
	GroupId  uint64 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"`
	SenderId uint64 `protobuf:"varint,2,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
	Content  []byte `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*GroupChatMessage) Descriptor deprecated

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

Deprecated: Use GroupChatMessage.ProtoReflect.Descriptor instead.

func (*GroupChatMessage) GetContent

func (x *GroupChatMessage) GetContent() []byte

func (*GroupChatMessage) GetGroupId

func (x *GroupChatMessage) GetGroupId() uint64

func (*GroupChatMessage) GetSenderId

func (x *GroupChatMessage) GetSenderId() uint64

func (*GroupChatMessage) ProtoMessage

func (*GroupChatMessage) ProtoMessage()

func (*GroupChatMessage) ProtoReflect

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

func (*GroupChatMessage) Reset

func (x *GroupChatMessage) Reset()

func (*GroupChatMessage) String

func (x *GroupChatMessage) String() string

type Message

type Message struct {
	Version   uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	MagicNum  uint32 `protobuf:"varint,2,opt,name=magic_num,json=magicNum,proto3" json:"magic_num,omitempty"`
	Operation uint32 `protobuf:"varint,3,opt,name=operation,proto3" json:"operation,omitempty"` //区分消息类型
	Sequence  uint32 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"`
	Data      []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` //消息内容
	// contains filtered or unexported fields
}

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) FromBytes

func (m *Message) FromBytes(data []byte) (err error)

func (*Message) GetData

func (x *Message) GetData() []byte

func (*Message) GetMagicNum

func (x *Message) GetMagicNum() uint32

func (*Message) GetOperation

func (x *Message) GetOperation() uint32

func (*Message) GetSequence

func (x *Message) GetSequence() uint32

func (*Message) GetVersion

func (x *Message) GetVersion() uint32

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

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

func (*Message) ReadWebsocket

func (m *Message) ReadWebsocket(conn WebsocketReadWriter) (err error)

ReadWebsocket read a proto from websocket connection.

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

func (*Message) ToBytes

func (m *Message) ToBytes() []byte

func (*Message) WriteWebsocket

func (m *Message) WriteWebsocket(conn WebsocketReadWriter) (err error)

WriteWebsocket write a proto to websocket connection.

type ServiceMessage

type ServiceMessage struct {
	Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*ServiceMessage) Descriptor deprecated

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

Deprecated: Use ServiceMessage.ProtoReflect.Descriptor instead.

func (*ServiceMessage) GetContent

func (x *ServiceMessage) GetContent() []byte

func (*ServiceMessage) ProtoMessage

func (*ServiceMessage) ProtoMessage()

func (*ServiceMessage) ProtoReflect

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

func (*ServiceMessage) Reset

func (x *ServiceMessage) Reset()

func (*ServiceMessage) String

func (x *ServiceMessage) String() string

type TransMessage

type TransMessage struct {
	Type      uint32   `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` //消息的发送类型: Channel Room Broadcast
	Priority  uint32   `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"`
	Server    string   `protobuf:"bytes,3,opt,name=server,proto3" json:"server,omitempty"`
	Room      string   `protobuf:"bytes,4,opt,name=room,proto3" json:"room,omitempty"`
	Keys      []string `protobuf:"bytes,5,rep,name=keys,proto3" json:"keys,omitempty"`
	Operation uint32   `protobuf:"varint,6,opt,name=operation,proto3" json:"operation,omitempty"`
	Sequence  uint32   `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"`
	Data      []byte   `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*TransMessage) Descriptor deprecated

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

Deprecated: Use TransMessage.ProtoReflect.Descriptor instead.

func (*TransMessage) GetData

func (x *TransMessage) GetData() []byte

func (*TransMessage) GetKeys

func (x *TransMessage) GetKeys() []string

func (*TransMessage) GetOperation

func (x *TransMessage) GetOperation() uint32

func (*TransMessage) GetPriority

func (x *TransMessage) GetPriority() uint32

func (*TransMessage) GetRoom

func (x *TransMessage) GetRoom() string

func (*TransMessage) GetSequence

func (x *TransMessage) GetSequence() uint32

func (*TransMessage) GetServer

func (x *TransMessage) GetServer() string

func (*TransMessage) GetType

func (x *TransMessage) GetType() uint32

func (*TransMessage) ProtoMessage

func (*TransMessage) ProtoMessage()

func (*TransMessage) ProtoReflect

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

func (*TransMessage) Reset

func (x *TransMessage) Reset()

func (*TransMessage) String

func (x *TransMessage) String() string

type WebsocketReadWriter

type WebsocketReadWriter interface {
	ReadMessage() (messageType int, p []byte, err error)
	WriteMessage(messageType int, data []byte) error
}

Jump to

Keyboard shortcuts

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