Documentation ¶
Index ¶
- Constants
- func RegMessageDef(def Message)
- type DefineST
- type EchoReq
- type EchoRsp
- type Header
- type HeaderRsp
- type HeartbeatReq
- type HeartbeatRsp
- type Message
- type Packet
- type ProtocolSet
- type STConnectionConfig
- type STServerStatus
- type SignInReq
- type SignInRsp
- type UDPHeader
- type UDPHelloReq
- type UDPHelloRsp
Constants ¶
View Source
const ( ProtoIDHeartbeatReq = uint32(1) ProtoIDHeartbeatRsp = uint32(2) ProtoIDEchoReq = uint32(3) ProtoIDEchoRsp = uint32(4) ProtoIDSignInReq = uint32(5) ProtoIDSignInRsp = uint32(6) ProtoIDUDPHelloReq = uint32(225) ProtoIDUDPHelloRsp = uint32(226) )
ProtoID
View Source
const ( ErrCodeOK = uint32(0) //正确 ErrCodeFail = uint32(1) //总之失败 ErrCodeUnknown = uint32(2) //未知错误 ErrCodeInvalid = uint32(3) //无效 ErrCodeNotExist = uint32(4) //不存在 ErrCodeTimeout = uint32(5) //超时 )
ErrorCode
Variables ¶
This section is empty.
Functions ¶
func RegMessageDef ¶
func RegMessageDef(def Message)
Types ¶
type EchoReq ¶
type EchoReq struct {
Text string `json:"text,omitempty"`
}
消息: 回声
func NewEchoReq ¶
func NewEchoReq() *EchoReq
type EchoRsp ¶
type EchoRsp struct {
Text string `json:"text,omitempty"`
}
func NewEchoRsp ¶
func NewEchoRsp() *EchoRsp
type Header ¶ added in v0.1.0
type Header struct { CheckSum string `json:"cs,omitempty"` ProtoID uint32 `json:"p,omitempty"` Rsp *HeaderRsp `json:"rsp,omitempty"` Seq uint64 `json:"s,omitempty"` Tms uint64 `json:"t,omitempty"` }
消息头(header)
type HeaderRsp ¶
type HeaderRsp struct { ErrCode uint32 `json:"ec,omitempty"` ErrMessage string `json:"em,omitempty"` RequestSeq uint64 `json:"rs,omitempty"` RequestTms uint64 `json:"rt,omitempty"` }
func NewHeaderRsp ¶
func NewHeaderRsp() *HeaderRsp
type HeartbeatReq ¶
type HeartbeatReq struct { }
消息: 心跳
func NewHeartbeatReq ¶
func NewHeartbeatReq() *HeartbeatReq
func (*HeartbeatReq) Decode ¶
func (st *HeartbeatReq) Decode(bs []byte) error
func (*HeartbeatReq) Encode ¶
func (st *HeartbeatReq) Encode() ([]byte, error)
func (*HeartbeatReq) Name ¶
func (st *HeartbeatReq) Name() string
func (*HeartbeatReq) New ¶
func (st *HeartbeatReq) New() Message
func (*HeartbeatReq) NewST ¶
func (st *HeartbeatReq) NewST() DefineST
func (*HeartbeatReq) ProtoID ¶
func (st *HeartbeatReq) ProtoID() uint32
func (*HeartbeatReq) String ¶
func (st *HeartbeatReq) String() string
type HeartbeatRsp ¶
type HeartbeatRsp struct { //心跳的response被设计为投递模式, 所以需要显式的时间回执 BackTms uint64 `json:"backTms,omitempty"` }
func NewHeartbeatRsp ¶
func NewHeartbeatRsp() *HeartbeatRsp
func (*HeartbeatRsp) Decode ¶
func (st *HeartbeatRsp) Decode(bs []byte) error
func (*HeartbeatRsp) Encode ¶
func (st *HeartbeatRsp) Encode() ([]byte, error)
func (*HeartbeatRsp) Name ¶
func (st *HeartbeatRsp) Name() string
func (*HeartbeatRsp) New ¶
func (st *HeartbeatRsp) New() Message
func (*HeartbeatRsp) NewST ¶
func (st *HeartbeatRsp) NewST() DefineST
func (*HeartbeatRsp) ProtoID ¶
func (st *HeartbeatRsp) ProtoID() uint32
func (*HeartbeatRsp) String ¶
func (st *HeartbeatRsp) String() string
type ProtocolSet ¶ added in v0.1.0
type ProtocolSet interface { New(id uint32) Message Encode(msg Message) ([]byte, error) Decode(id uint32, bs []byte) (Message, error) }
var GlobalProtocolSet ProtocolSet = &defaultProtocolSet{}
type STConnectionConfig ¶ added in v0.1.0
type STConnectionConfig struct {
ConfoundCode []byte `json:"confoundCode,omitempty"`
}
func NewSTConnectionConfig ¶ added in v0.1.0
func NewSTConnectionConfig() *STConnectionConfig
func (*STConnectionConfig) Decode ¶ added in v0.1.0
func (st *STConnectionConfig) Decode(bs []byte) error
func (*STConnectionConfig) Encode ¶ added in v0.1.0
func (st *STConnectionConfig) Encode() ([]byte, error)
func (*STConnectionConfig) Name ¶ added in v0.1.0
func (st *STConnectionConfig) Name() string
func (*STConnectionConfig) NewST ¶ added in v0.1.0
func (st *STConnectionConfig) NewST() DefineST
func (*STConnectionConfig) String ¶ added in v0.1.0
func (st *STConnectionConfig) String() string
type STServerStatus ¶ added in v0.1.0
type STServerStatus struct {
ServerVersion string `json:"serverVersion,omitempty"`
}
func NewSTServerStatus ¶ added in v0.1.0
func NewSTServerStatus() *STServerStatus
func (*STServerStatus) Decode ¶ added in v0.1.0
func (st *STServerStatus) Decode(bs []byte) error
func (*STServerStatus) Encode ¶ added in v0.1.0
func (st *STServerStatus) Encode() ([]byte, error)
func (*STServerStatus) Name ¶ added in v0.1.0
func (st *STServerStatus) Name() string
func (*STServerStatus) NewST ¶ added in v0.1.0
func (st *STServerStatus) NewST() DefineST
func (*STServerStatus) String ¶ added in v0.1.0
func (st *STServerStatus) String() string
type SignInReq ¶ added in v0.1.0
type SignInReq struct { }
消息: 服务配置
func NewSignInReq ¶ added in v0.1.0
func NewSignInReq() *SignInReq
type SignInRsp ¶ added in v0.1.0
type SignInRsp struct { ConnConfig *STConnectionConfig `json:"connConfig,omitempty"` ConnID uint64 `json:"connID,omitempty"` ServerStatus *STServerStatus `json:"serverStatus,omitempty"` }
func NewSignInRsp ¶ added in v0.1.0
func NewSignInRsp() *SignInRsp
type UDPHeader ¶ added in v0.1.0
type UDPHeader struct {
Index uint64 `json:"i,omitempty"`
}
UDP的额外头部
func NewUDPHeader ¶ added in v0.1.0
func NewUDPHeader() *UDPHeader
type UDPHelloReq ¶ added in v0.1.0
type UDPHelloReq struct {
SignCode string `json:"signCode,omitempty"`
}
应为一个UDP客户端发送的第一个消息
func NewUDPHelloReq ¶ added in v0.1.0
func NewUDPHelloReq() *UDPHelloReq
func (*UDPHelloReq) Decode ¶ added in v0.1.0
func (st *UDPHelloReq) Decode(bs []byte) error
func (*UDPHelloReq) Encode ¶ added in v0.1.0
func (st *UDPHelloReq) Encode() ([]byte, error)
func (*UDPHelloReq) Name ¶ added in v0.1.0
func (st *UDPHelloReq) Name() string
func (*UDPHelloReq) New ¶ added in v0.1.0
func (st *UDPHelloReq) New() Message
func (*UDPHelloReq) NewST ¶ added in v0.1.0
func (st *UDPHelloReq) NewST() DefineST
func (*UDPHelloReq) ProtoID ¶ added in v0.1.0
func (st *UDPHelloReq) ProtoID() uint32
func (*UDPHelloReq) String ¶ added in v0.1.0
func (st *UDPHelloReq) String() string
type UDPHelloRsp ¶ added in v0.1.0
type UDPHelloRsp struct {
Index uint64 `json:"index,omitempty"`
}
应为一个UDP客户端接收的第一个消息
func NewUDPHelloRsp ¶ added in v0.1.0
func NewUDPHelloRsp() *UDPHelloRsp
func (*UDPHelloRsp) Decode ¶ added in v0.1.0
func (st *UDPHelloRsp) Decode(bs []byte) error
func (*UDPHelloRsp) Encode ¶ added in v0.1.0
func (st *UDPHelloRsp) Encode() ([]byte, error)
func (*UDPHelloRsp) Name ¶ added in v0.1.0
func (st *UDPHelloRsp) Name() string
func (*UDPHelloRsp) New ¶ added in v0.1.0
func (st *UDPHelloRsp) New() Message
func (*UDPHelloRsp) NewST ¶ added in v0.1.0
func (st *UDPHelloRsp) NewST() DefineST
func (*UDPHelloRsp) ProtoID ¶ added in v0.1.0
func (st *UDPHelloRsp) ProtoID() uint32
func (*UDPHelloRsp) String ¶ added in v0.1.0
func (st *UDPHelloRsp) String() string
Click to show internal directories.
Click to hide internal directories.