Documentation
¶
Index ¶
- Constants
- Variables
- func CodeToMessage(code int) string
- type Command
- type GBuffer
- func (gBuffer *GBuffer) Bytes() []byte
- func (gBuffer *GBuffer) Len() int
- func (gBuffer *GBuffer) ReadArray(version uint16) ([]IMessage, error)
- func (gBuffer *GBuffer) ReadBytes() ([]byte, error)
- func (gBuffer *GBuffer) ReadInt16(v *int16) error
- func (gBuffer *GBuffer) ReadInt32(v *int32) error
- func (gBuffer *GBuffer) ReadInt64(v *int64) error
- func (gBuffer *GBuffer) ReadInt8(v *int8) error
- func (gBuffer *GBuffer) ReadRawBytes(l uint16) ([]byte, error)
- func (gBuffer *GBuffer) ReadString() (string, error)
- func (gBuffer *GBuffer) ReadStruct(version uint16, iMessage IMessage) error
- func (gBuffer *GBuffer) ReadUInt16(v *uint16) error
- func (gBuffer *GBuffer) ReadUInt32(v *uint32) error
- func (gBuffer *GBuffer) ReadUInt64(v *uint64) error
- func (gBuffer *GBuffer) ReadUInt8(v *uint8) error
- func (gBuffer *GBuffer) WriteArray(version uint16, arr interface{}) error
- func (gBuffer *GBuffer) WriteBytes(b []byte) error
- func (gBuffer *GBuffer) WriteInt16(v int16) error
- func (gBuffer *GBuffer) WriteInt32(v int32) error
- func (gBuffer *GBuffer) WriteInt64(v int64) error
- func (gBuffer *GBuffer) WriteInt8(v int8) error
- func (gBuffer *GBuffer) WriteRawBytes(b []byte) error
- func (gBuffer *GBuffer) WriteString(str string) error
- func (gBuffer *GBuffer) WriteStruct(version uint16, iMessage IMessage) error
- func (gBuffer *GBuffer) WriteUInt16(v uint16) error
- func (gBuffer *GBuffer) WriteUInt32(v uint32) error
- func (gBuffer *GBuffer) WriteUInt64(v uint64) error
- func (gBuffer *GBuffer) WriteUInt8(v uint8) error
- type GProtoAuthRequest
- type GProtoAuthResponse
- type GProtoBlacklist
- type GProtoChatRoomInfo
- type GProtoChatRoomKickoffNotify
- type GProtoEchoRequest
- type GProtoEchoResponse
- type GProtoEnterChatRoomNotify
- type GProtoEnterChatRoomRequest
- type GProtoEnterChatRoomResponse
- type GProtoFriend
- type GProtoGetChatRoomInfoRequest
- type GProtoGetChatRoomInfoResponse
- type GProtoGroupInfo
- type GProtoGroupMarkname
- type GProtoKickOffNotify
- type GProtoLeaveChatRoomNotify
- type GProtoLeaveChatRoomRequest
- type GProtoLeaveChatRoomResponse
- type GProtoMessageAck
- type GProtoMessageNotify
- type GProtoMessageRequest
- type GProtoMessageResponse
- type GProtoOtherUser
- type GProtoPingRequest
- type GProtoPingResponse
- type GProtoSelfUser
- type GProtoTouchChatRoomRequest
- type GProtoTouchChatRoomResponse
- type IMessage
- type Message
- type MessageCreator
Constants ¶
View Source
const ( CODE_SUCCESS = 0 // Success CODE_IGNORE = 1 // Ignore CODE_ERROR_NO_USER = 2 // User Not Found CODE_ERROR_PASSWORD_ERROR = 3 // Password Error CODE_ERROR_UNKNOWN = 4 // Unknown Error CODE_ERROR_REPLACED = 5 // Session Replaced CODE_ERROR_CLIENT = 6 // Client Logci Error CODE_ERROR_SERVER = 7 // Server Internal Error CODE_ERROR_DB = 8 // DB Ops Error CODE_ERROR_NOT_FOUND = 9 // Not Found Error CODE_ERROR_AUTH_ERROR = 10 // AUTH Error CODE_ERROR_UNSUPPORT_API = 11 // UnSupport API CODE_ERROR_INVALID_JSON = 12 // Invalid JSON Format CODE_ERROR_ALREADY_REGISTERED = 13 // Already Registered Error CODE_ERROR_NO_APP = 14 // No App Error CODE_ERROR_ALREADY_EXIST = 15 // Already Exist )
全局错误码
View Source
const ( MSG_PING_REQUEST = 0x1001 // C -> S MSG_PING_RESPONSE = 0x1002 // S -> C MSG_ECHO_REQUEST = 0x1003 // C -> S MSG_ECHO_RESPONSE = 0x1004 // S -> C MSG_KICKOFF_NOTIFY = 0x1005 // S -> C MSG_AUTH_REQUEST = 0x1006 // C -> S MSG_AUTH_RESPONSE = 0x1007 // S -> C MSG_MESSAGE_REQUEST = 0x100e // C -> S MSG_MESSAGE_RESPONSE = 0x100f // S -> C MSG_MESSAGE_NOTIFY = 0x1010 // S -> C MSG_MESSAGE_ACK = 0x1011 // C -> S MSG_GET_CHATROOM_INFO_REQUEST = 0x101d // C -> S MSG_GET_CHATROOM_INFO_RESPONSE = 0x101e // S -> S MSG_ENTER_CHATROOM_REQUEST = 0x101f // C -> S MSG_ENTER_CHATROOM_RESPONSE = 0x1020 // S -> C MSG_TOUCH_CHATROOM_REQUEST = 0x1021 // C -> S MSG_TOUCH_CHATROOM_RESPONSE = 0x1022 // S -> C MSG_ENTER_CHATROOM_NOTIFY = 0x1023 // S -> C MSG_LEAVE_CHATROOM_REQUEST = 0x1024 // C -> S MSG_LEAVE_CHATROOM_RESPONSE = 0x1025 // S -> C MSG_LEAVE_CHATROOM_NOTIFY = 0x1026 // S -> C MSG_CHATROOM_KICKOFF_NOTIFY = 0x1027 // S -> C )
View Source
const ( OPTIONAL_TRUE = 1 // 字段写入 OPTIONAL_FALSE = 0 // 字段不写(忽略), 默认值 )
optional字段前缀
View Source
const ( // 0 - 9 MESSAGE_TYPE_PLAYER_TEXT = 0 MESSAGE_TYPE_PLAYER_IMAGE = 1 MESSAGE_TYPE_PLAYER_SHORT_VOICE = 2 MESSAGE_TYPE_PLAYER_SHORT_VEDEO = 3 MESSAGE_TYPE_PLAYER_CUSTOMIZE_ONLINE = 4 // 自定义格式消息(不会离线存储) MESSAGE_TYPE_PLAYER_CUSTOMIZE_OFFLINE = 5 // 自定义格式消息(会离线存储) // 10 - 19 MESSAGE_TYPE_GROUP_TEXT = 10 MESSAGE_TYPE_GROUP_IMAGE = 11 MESSAGE_TYPE_GROUP_SHORT_VOICE = 12 MESSAGE_TYPE_GROUP_SHORT_VEDEO = 13 MESSAGE_TYPE_GROUP_CUSTOMIZE_ONLINE = 14 // 自定义格式消息(不会离线存储) MESSAGE_TYPE_GROUP_CUSTOMIZE_OFFLINE = 15 // 自定义格式消息(会离线存储) // 20 - 29 MESSAGE_TYPE_CHATROOM_TEXT = 20 MESSAGE_TYPE_CHATROOM_IMAGE = 21 MESSAGE_TYPE_CHATROOM_SHORT_VOICE = 22 MESSAGE_TYPE_CHATROOM_SHORT_VEDEO = 23 MESSAGE_TYPE_CHATROOM_CUSTOMIZE_ONLINE = 24 // 自定义格式消息(不会离线存储) // 30 - 39 MESSAGE_TYPE_BROADCAST_TEXT = 30 // (不会离线存储) MESSAGE_TYPE_BROADCAST_IMAGE = 31 // (不会离线存储) MESSAGE_TYPE_BROADCAST_SHORT_VOICE = 32 // (不会离线存储) MESSAGE_TYPE_BROADCAST_SHORT_VIDEO = 33 // (不会离线存储) MESSAGE_TYPE_BROADCAST_CUSTOMIZE_ONLINE = 34 // 自定义格式消息(不会离线存储) )
View Source
const (
MagicWord = 0x7fffffff // 4 bytes
)
Variables ¶
View Source
var ( InvalidDecodeBufferError = errors.New("invalid Decode Buffer") InvalidVersionError = errors.New("invalid Version") )
Functions ¶
func CodeToMessage ¶
Types ¶
type GBuffer ¶
func (*GBuffer) ReadString ¶
func (*GBuffer) ReadStruct ¶
func (*GBuffer) ReadUInt16 ¶
func (*GBuffer) ReadUInt32 ¶
func (*GBuffer) ReadUInt64 ¶
func (*GBuffer) WriteInt16 ¶
func (*GBuffer) WriteInt32 ¶
func (*GBuffer) WriteInt64 ¶
func (*GBuffer) WriteString ¶
func (*GBuffer) WriteStruct ¶
<3> Struct虚拟的约束 uint16长度 + 具体字节流
func (*GBuffer) WriteUInt16 ¶
func (*GBuffer) WriteUInt32 ¶
func (*GBuffer) WriteUInt64 ¶
func (*GBuffer) WriteUInt8 ¶
type GProtoAuthRequest ¶
type GProtoAuthResponse ¶
type GProtoBlacklist ¶
type GProtoChatRoomInfo ¶
type GProtoChatRoomInfo struct { ChatRoomId string Name string Description string OwnerAccount string MaxUser uint16 CreatedTimestamp int64 }
type GProtoChatRoomKickoffNotify ¶
//////////////////////////////////
message ChatRoomKickoffNotify { required string chatroom_id = 1; required string account = 2; }
type GProtoEchoRequest ¶
type GProtoEchoRequest struct {
Data string
}
type GProtoEchoResponse ¶
type GProtoEnterChatRoomNotify ¶
type GProtoEnterChatRoomNotify struct { ChatRoomId string User *GProtoOtherUser }
type GProtoEnterChatRoomRequest ¶
type GProtoEnterChatRoomRequest struct {
ChatRoomId string
}
type GProtoEnterChatRoomResponse ¶
type GProtoEnterChatRoomResponse struct { Code uint8 Users []*GProtoOtherUser }
type GProtoFriend ¶
type GProtoGetChatRoomInfoRequest ¶
type GProtoGetChatRoomInfoRequest struct {
ChatRoomId string
}
type GProtoGetChatRoomInfoResponse ¶
type GProtoGetChatRoomInfoResponse struct { Code uint8 Info *GProtoChatRoomInfo }
type GProtoGroupInfo ¶
type GProtoGroupInfo struct { GroupId string Name string Avatar string Description string OwnerAccount string MaxUser uint16 Flag uint8 CreatedTimestamp int64 Users []*GProtoOtherUser Marknames []*GProtoGroupMarkname }
type GProtoGroupMarkname ¶
type GProtoKickOffNotify ¶
type GProtoKickOffNotify struct {
Code uint8
}
type GProtoLeaveChatRoomNotify ¶
type GProtoLeaveChatRoomRequest ¶
type GProtoLeaveChatRoomRequest struct {
ChatRoomId string
}
type GProtoLeaveChatRoomResponse ¶
type GProtoMessageAck ¶
type GProtoMessageAck struct {
MsgId string
}
type GProtoMessageNotify ¶
type GProtoMessageNotify struct { MsgId string MsgType uint8 Content string RoomId string From string To string SendTime uint64 SendTimeAck uint64 Extend string }
func MessageRequestToMessageNotify ¶
func MessageRequestToMessageNotify(gProtoMessageRequest *GProtoMessageRequest) *GProtoMessageNotify
type GProtoMessageRequest ¶
type GProtoMessageRequest struct { MsgId string MsgType uint8 Content string RoomId string From string To string Extend string }
type GProtoMessageResponse ¶
type GProtoOtherUser ¶
type GProtoOtherUser struct {
Account string
}
func EmptyGProtoOtherUser ¶
func EmptyGProtoOtherUser(account string) *GProtoOtherUser
func (*GProtoOtherUser) Decode ¶
func (otherUser *GProtoOtherUser) Decode(version uint16, buf []byte) error
func (*GProtoOtherUser) Encode ¶
func (otherUser *GProtoOtherUser) Encode(version uint16) ([]byte, error)
func (*GProtoOtherUser) String ¶
func (otherUser *GProtoOtherUser) String() string
type GProtoPingRequest ¶
type GProtoPingRequest struct { }
type GProtoPingResponse ¶
type GProtoPingResponse struct {
Code uint8
}
type GProtoSelfUser ¶
type GProtoSelfUser struct {
Account string
}
func EmptyGProtoSelfUser ¶
func EmptyGProtoSelfUser(account string) *GProtoSelfUser
func (*GProtoSelfUser) Decode ¶
func (selfUser *GProtoSelfUser) Decode(version uint16, buf []byte) error
func (*GProtoSelfUser) Encode ¶
func (selfUser *GProtoSelfUser) Encode(version uint16) ([]byte, error)
func (*GProtoSelfUser) String ¶
func (selfUser *GProtoSelfUser) String() string
type GProtoTouchChatRoomRequest ¶
type GProtoTouchChatRoomRequest struct {
ChatRoomId string
}
房间心跳
type GProtoTouchChatRoomResponse ¶
type GProtoTouchChatRoomResponse struct {
Code uint8
}
type Message ¶
type Message struct { MagicWord uint32 Version uint16 Command uint16 PayloadLength uint32 Body interface{} // IMessage }
func NewEmptyMessage ¶
func NewEmptyMessage() *Message
func NewMessage ¶
func (*Message) DecodeHead ¶
func (*Message) EncodeHead ¶
Click to show internal directories.
Click to hide internal directories.