Documentation ¶
Index ¶
- Variables
- func DecodeMessage(s ISession, data []byte)
- func ForEachMessageMeta(callback func(*MessageMeta))
- func MessageFullName(rtype reflect.Type) string
- func MessageNameByID(id uint32) string
- func RegisterMessageFunction(f MessageFunc)
- func RegisterMessageMeta(id uint32, name string, msgType reflect.Type)
- func ReplyMessage(header *Message, msg interface{}, status uint8) []byte
- func RequestMessage(msg interface{}, status, serializeType uint8, indexID uint32) []byte
- type ISession
- type Message
- type MessageFunc
- type MessageMeta
- type MessageStatusType
- type MessageType
- type OnCloseFunc
- type OnConnectFunc
- type SerializeType
- type SessionManager
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Codecs are codecs supported by rpc. You can add customized codecs in Codecs. Codecs = map[SerializeType]codec.Codec{ ProtoBuffer: &codec.PBCodec{}, JSON: &codec.JSONCodec{}, } )
Functions ¶
func DecodeMessage ¶
func ForEachMessageMeta ¶
func ForEachMessageMeta(callback func(*MessageMeta))
ForEachMessageMeta 遍历消息元信息
func RegisterMessageFunction ¶
func RegisterMessageFunction(f MessageFunc)
RegisterMessageFunction call outside
func RegisterMessageMeta ¶
RegisterMessageMeta 注册消息元信息(代码生成专用)
func ReplyMessage ¶
func RequestMessage ¶
Types ¶
type Message ¶
type Message struct { MsgId uint32 Index uint32 SerializeType uint8 MessageType uint8 Status uint8 GateSessionId int64 Data []byte }
Message tcp & webscoket share message struct
type MessageFunc ¶
type MessageMeta ¶
func MessageMetaByName ¶
func MessageMetaByName(name string) *MessageMeta
MessageMetaByName 根据名字查找消息元信息
func MessageMetaByType ¶
func MessageMetaByType(t reflect.Type) *MessageMeta
MessageMetaByType 根据类型查找消息元消息
type MessageStatusType ¶
type MessageStatusType byte
MessageStatusType is status of messages.
const ( // Normal is normal requests and responses. Normal MessageStatusType = iota // Error indicates some errors occur. Error )
type MessageType ¶
type MessageType byte
MessageType is message type of requests and resposnes.
const ( // Request is message type of request Request MessageType = iota // Response is message type of response Response )
type OnCloseFunc ¶
type OnCloseFunc func(session ISession)
type OnConnectFunc ¶
type OnConnectFunc func(session ISession)
type SerializeType ¶
type SerializeType byte
SerializeType defines serialization type of Data.
const ( // ProtoBuffer for payload. ProtoBuffer SerializeType = iota // JSON for payload. JSON )
type SessionManager ¶
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) Add ¶
func (sm *SessionManager) Add(session ISession)
func (*SessionManager) CloseAll ¶
func (sm *SessionManager) CloseAll()
func (*SessionManager) Get ¶
func (sm *SessionManager) Get(sid int64) ISession
func (*SessionManager) Len ¶
func (sm *SessionManager) Len() int
func (*SessionManager) Remove ¶
func (sm *SessionManager) Remove(session ISession)
Click to show internal directories.
Click to hide internal directories.