Documentation
¶
Index ¶
- Constants
- Variables
- func Byte4ToUint32(data []byte) (result uint32)
- func CombineMsgWithId(msgId int32, data []byte) []byte
- func GenSessionId() uint64
- func Uint32ToByte4(data uint32) (result []byte)
- type Client
- type DecodeEncoder
- type Listener
- type Message
- type Session
- type SessionHandler
- type SessionType
- type StreamCode
- type TcpClient
- type TcpListener
- type TcpSession
- func (s *TcpSession) DeleteKV(key interface{})
- func (s *TcpSession) Id() uint64
- 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
- type WSCode
- type WSSession
- func (s *WSSession) Context() context.Context
- func (s *WSSession) DeleteKV(key interface{})
- func (s *WSSession) Id() uint64
- func (s *WSSession) Load(key interface{}) (value interface{}, ok bool)
- func (s *WSSession) LocalAddr() net.Addr
- func (s *WSSession) RemoteAddr() net.Addr
- func (s *WSSession) RemoteIP() string
- func (s *WSSession) SendMsg(msg []byte) error
- func (s *WSSession) Stop()
- func (s *WSSession) StoreKV(key, value interface{})
- func (s *WSSession) Type() SessionType
- type WebSocketListener
Constants ¶
View Source
const ( StreamHeadLen = 4 * tools.B MaxMsgLen = 100 * tools.MB )
Variables ¶
View Source
var ErrRecvLen = errors.New("data is too long")
Functions ¶
func Byte4ToUint32 ¶
func CombineMsgWithId ¶
func GenSessionId ¶ added in v1.2.21
func GenSessionId() uint64
func Uint32ToByte4 ¶
Types ¶
type Client ¶ added in v1.1.19
type Client interface { SendMsg([]byte) error AddHandler(handler func() SessionHandler) Start(reconnect bool) error Stop() }
func NewTcpClient ¶
func NewTcpClient(addr string, newCodec func() DecodeEncoder) Client
type DecodeEncoder ¶ added in v1.1.19
type Listener ¶ added in v1.1.19
func StartTcpListen ¶
func StartTcpListen(addr string, newCodec func() DecodeEncoder, newHandler func() SessionHandler) Listener
func StartWSListen ¶ added in v1.4.2
func StartWSListen(addr string, newCodec func() DecodeEncoder, newHandler func() SessionHandler) Listener
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewBytesMessageParse ¶
func NewBytesMessageParse(data []byte, mm *tools.ProtoIndex) *Message
NewBytesMessageParse 远端actor通信主要使用接口
func NewPbMessage ¶
NewPbMessage 业务逻辑层主要使用接口
type SessionHandler ¶ added in v1.2.21
type SessionType ¶
type SessionType int
const ( TypeTCP SessionType = 1 TypeUDP SessionType = 2 TypeWS SessionType = 3 )
type StreamCode ¶ added in v1.1.19
type StreamCode struct { MaxDecode uint64 // contains filtered or unexported fields }
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) AddHandler ¶ added in v1.2.16
func (s *TcpClient) AddHandler(handler func() SessionHandler)
AddHandler add handler to tail of list
type TcpListener ¶
type TcpListener struct {
// contains filtered or unexported fields
}
func (*TcpListener) Port ¶ added in v1.4.7
func (s *TcpListener) Port() int
func (*TcpListener) Start ¶
func (s *TcpListener) Start(exceptPort ...int) 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() uint64
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
type WSCode ¶ added in v1.4.2
type WSCode struct { MaxDecode uint64 // contains filtered or unexported fields }
type WSSession ¶ added in v1.4.2
type WSSession struct {
// contains filtered or unexported fields
}
func (*WSSession) RemoteAddr ¶ added in v1.4.2
func (*WSSession) Type ¶ added in v1.4.2
func (s *WSSession) Type() SessionType
type WebSocketListener ¶ added in v1.4.2
type WebSocketListener struct {
// contains filtered or unexported fields
}
func (*WebSocketListener) Port ¶ added in v1.4.7
func (w *WebSocketListener) Port() int
func (*WebSocketListener) Start ¶ added in v1.4.2
func (w *WebSocketListener) Start(exceptPort ...int) error
func (*WebSocketListener) Stop ¶ added in v1.4.2
func (w *WebSocketListener) Stop()
Click to show internal directories.
Click to hide internal directories.