Documentation
¶
Index ¶
- Constants
- Variables
- func Byte4ToUint32(data []byte) (result uint32)
- func CombineMsgWithId(msgId int32, data []byte) []byte
- func Uint32ToByte4(data uint32) (result []byte)
- type Client
- type DecodeEncoder
- type EchoCode
- type Listener
- type Message
- type NetSession
- type NetSessionHandler
- type OptionClient
- type OptionListen
- type SessionType
- type StreamCode
- type TcpClient
- type TcpListener
- type TcpSession
- func (s *TcpSession) DeleteKV(key interface{})
- func (s *TcpSession) Id() uint32
- func (s *TcpSession) Load(key interface{}) (value interface{}, ok bool)
- func (s *TcpSession) LocalAddr() net.Addr
- func (s *TcpSession) RemoteAddr() net.Addr
- func (s *TcpSession) RemoteIP() string
- func (s *TcpSession) SendMsg(msg []byte) error
- func (s *TcpSession) Stop()
- func (s *TcpSession) StoreKV(key, value interface{})
- func (s *TcpSession) Type() SessionType
Constants ¶
View Source
const STREAM_HEADLEN = 4
Variables ¶
View Source
var ErrRecvLen = errors.New("data is too long")
View Source
var GenNetSessionId = _gen_net_session_id()
Functions ¶
func Byte4ToUint32 ¶
func CombineMsgWithId ¶
func Uint32ToByte4 ¶
Types ¶
type Client ¶ added in v1.1.19
type Client interface { SendMsg([]byte) error AddLast(hander func() NetSessionHandler) Start(reconect bool) error Stop() }
func NewTcpClient ¶
func NewTcpClient(addr string, newCodec func() DecodeEncoder, op ...OptionClient) Client
type DecodeEncoder ¶ added in v1.1.19
type EchoCode ¶ added in v1.1.19
type EchoCode struct { MaxDecode int // contains filtered or unexported fields }
type Listener ¶ added in v1.1.19
type Listener interface { Start() error Stop() }
func StartTcpListen ¶
func StartTcpListen(addr string, newCodec func() DecodeEncoder, newHandler func() NetSessionHandler, op ...OptionListen) Listener
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewBytesMessageParse ¶
func NewBytesMessageParse(data []byte, mm *tools.ProtoIndex) *Message
远端actor通信主要使用接口
type NetSession ¶ added in v1.1.19
type NetSessionHandler ¶ added in v1.1.19
type NetSessionHandler interface { OnSessionCreated(NetSession) OnSessionClosed() OnRecv([]byte) }
type OptionClient ¶
type OptionClient func(l *TcpClient)
type OptionListen ¶
type OptionListen func(l *TcpListener)
type SessionType ¶
type SessionType int
const ( TYPE_TCP SessionType = 1 TYPE_UDP SessionType = 2 TYPE_WS SessionType = 3 )
type StreamCode ¶ added in v1.1.19
type StreamCode struct { MaxDecode int // contains filtered or unexported fields }
├──── 4bytes ─────┼────────────── body size ─────────────────┤ ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ head(body size) ┃ body (data) ┃ ┗━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ├──────────── MAX Size:StreamCode.MaxDecode ────────────────┤
func (*StreamCode) Decode ¶ added in v1.1.19
func (s *StreamCode) Decode(data []byte) ([][]byte, error)
func (*StreamCode) Encode ¶ added in v1.1.19
func (s *StreamCode) Encode(data []byte) []byte
type TcpClient ¶
type TcpClient struct {
// contains filtered or unexported fields
}
func (*TcpClient) AddLast ¶
func (s *TcpClient) AddLast(hander func() NetSessionHandler)
add handler to last of list
type TcpListener ¶
type TcpListener struct {
// contains filtered or unexported fields
}
func (*TcpListener) Start ¶
func (s *TcpListener) Start() error
func (*TcpListener) Stop ¶
func (s *TcpListener) Stop()
type TcpSession ¶
type TcpSession struct {
// contains filtered or unexported fields
}
func (*TcpSession) DeleteKV ¶
func (s *TcpSession) DeleteKV(key interface{})
func (*TcpSession) Id ¶
func (s *TcpSession) Id() uint32
func (*TcpSession) Load ¶
func (s *TcpSession) Load(key interface{}) (value interface{}, ok bool)
func (*TcpSession) LocalAddr ¶
func (s *TcpSession) LocalAddr() net.Addr
func (*TcpSession) RemoteAddr ¶
func (s *TcpSession) RemoteAddr() net.Addr
func (*TcpSession) RemoteIP ¶
func (s *TcpSession) RemoteIP() string
func (*TcpSession) SendMsg ¶
func (s *TcpSession) SendMsg(msg []byte) error
func (*TcpSession) Stop ¶
func (s *TcpSession) Stop()
func (*TcpSession) StoreKV ¶
func (s *TcpSession) StoreKV(key, value interface{})
func (*TcpSession) Type ¶
func (s *TcpSession) Type() SessionType
Click to show internal directories.
Click to hide internal directories.