Versions in this module Expand all Collapse all v1 v1.0.0 Apr 10, 2023 Changes in this version + const DefaultMaxConnect + const EncodingTypeBinary + const EncodingTypeGPB + const EncodingTypeGob + const EncodingTypeMax + const EncodingTypeNil + const InterestOps_Closed + const InterestOps_Idle + const InterestOps_Max + const InterestOps_Opened + const InterestOps_Received + const InterestOps_Sent + const IoServiceMaxCount + const RWBufRecyclerBacklog + const ReconnectInterval + var Bcd = &BinaryEncDecoder + var Config = Configuration + var ConnectorMgr = &connectorMgr + var DefaultBuiltinProtocolEncoder = &DefaultProtocolEncoder + var DefaultProtocoDecoderName = "default-protocol-decoder" + var DefaultProtocolEncoderName = "default-protocol-encoder" + var ErrExceedMaxPacketSize = errors.New("exceed max packet size") + var ErrRcvBufCannotGet = errors.New("Session rcvbuf get failed") + var ErrSndBufCannotGet = errors.New("Session sndbuf get failed") + var ErrorTypeNotFit = errors.New("packet not proto.Message type") + var Gob = &GobEncDecoder + var Gpb = &GbpEncDecoder + var LenOfPacketHeader int + var LenOfProtoHeader int + var MaxPacketSize int = 64 * 1024 + var NetModule = newNetEngine() + var Nil = &NilEncDecoder + var RWRecycler = recycler.NewRecycler(RWBufRecyclerBacklog, func() interface{} { ... }, "rwbuf_recycler") + var SendRoutinePoison *packet = nil + func AllocAction() *action + func AllocPacket() *packet + func BenchmarkAllocAction(b *testing.B) + func Connect(sc *SessionConfig) error + func CreatePacket(packetId int) interface + func FreeAction(a *action) + func FreePacket(p *packet) + func FreeRWBuf(buf *RWBuffer) + func GetPacketTypeAndId(pack interface{}) (int, int) + func Listen(sc *SessionConfig) error + func MarshalPacket(packetid int, pack interface{}) ([]byte, error) + func MarshalPacketNoPackId(pack interface{}) (data []byte, err error) + func RegisteEncoding(edtype int, ed EncDecoder, tt TypeTester) + func RegisteErrorPacketHandlerCreator(name string, ephc ErrorPacketHandlerCreator) + func RegisteProtocolDecoder(name string, dec ProtocolDecoder) + func RegisteProtocolEncoder(name string, enc ProtocolEncoder) + func RegisteSessionFilterCreator(filterName string, sfc SessionFilterCreator) + func RegisteSessionHandlerCreator(name string, shc SessionHandlerCreator) + func Register1ToMHandler(h Handler, packetIds ...int) + func RegisterFactory(packetId int, factory PacketFactory) + func RegisterHandler(packetId int, h Handler) + func RegisterRangeHandler(start, end int, h Handler) + func SendStartNetIoService(sc *SessionConfig) bool + func ShutConnector(ip string, port int) + func Stats() map[int]ServiceStats + func TestAllocAction(t *testing.T) + func TestFreeAction(t *testing.T) + func UnmarshalPacket(data []byte) (int, interface{}, error) + func UnmarshalPacketNoPackId(data []byte, pck interface{}) error + type Acceptor interface + Addr func() net.Addr + GetSessionConfig func() *SessionConfig + func GetAcceptors() []Acceptor + type ActionPool struct + func NewActionPool(num int) *ActionPool + func (ap *ActionPool) Get() (a *action) + func (ap *ActionPool) Give(a *action) + type BasicSessionHandler struct + func (bsh *BasicSessionHandler) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) + func (bsh *BasicSessionHandler) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) + func (bsh *BasicSessionHandler) OnSessionClosed(s *Session) + func (bsh *BasicSessionHandler) OnSessionIdle(s *Session) + func (bsh *BasicSessionHandler) OnSessionOpened(s *Session) + type BinaryEncDecoder struct + func (this *BinaryEncDecoder) Marshal(pack interface{}) ([]byte, error) + func (this *BinaryEncDecoder) Unmarshal(buf []byte, pack interface{}) error + type Configuration struct + IoServices []SessionConfig + SrvInfo ServerInfo + func (c *Configuration) Close() error + func (c *Configuration) Init() error + func (c *Configuration) Name() string + type Connector interface + GetSessionConfig func() *SessionConfig + type DefaultProtocolDecoder struct + func (pdi *DefaultProtocolDecoder) Decode(s *Session, r io.Reader) (packetid int, logicNo uint32, packet interface{}, err error, raw []byte) + func (pdi *DefaultProtocolDecoder) FinishDecode(s *Session) + type DefaultProtocolEncoder struct + PacketCutor PacketCutSlicesFunc + func (dec *DefaultProtocolEncoder) CutAndSendPacket(s *Session, logicNo uint32, data []byte, w io.Writer) (err error) + func (dec *DefaultProtocolEncoder) Encode(s *Session, packetid int, logicNo uint32, packet interface{}, w io.Writer) (data []byte, err error) + func (dec *DefaultProtocolEncoder) FinishEncode(s *Session) + type EncDecoder interface + Marshal func(pack interface{}) ([]byte, error) + Unmarshal func(buf []byte, pack interface{}) error + type ErrorPacketHandler interface + OnErrorPacket func(s *Session, packetid int, logicNo uint32, data []byte) bool + type ErrorPacketHandlerCreator func() ErrorPacketHandler + func GetErrorPacketHandlerCreator(name string) ErrorPacketHandlerCreator + type ErrorPacketHandlerWrapper func(session *Session, packetid int, logicNo uint32, data []byte) bool + func (hw ErrorPacketHandlerWrapper) OnErrorPacket(session *Session, packetid int, logicNo uint32, data []byte) bool + type GbpEncDecoder struct + func (this *GbpEncDecoder) Marshal(pack interface{}) ([]byte, error) + func (this *GbpEncDecoder) Unmarshal(buf []byte, pack interface{}) error + type GobEncDecoder struct + func (this *GobEncDecoder) Marshal(pack interface{}) ([]byte, error) + func (this *GobEncDecoder) Unmarshal(buf []byte, pack interface{}) error + type Handler interface + Process func(session *Session, packetid int, data interface{}) error + func GetHandler(packetId int) Handler + type HandlerWrapper func(session *Session, packetid int, data interface{}) error + func (hw HandlerWrapper) Process(session *Session, packetid int, data interface{}) error + type ISession interface + Close func() + FireConnectEvent func() bool + FireDisconnectEvent func() bool + FirePacketReceived func(packetid int, logicNo uint32, packet interface{}) bool + FirePacketSent func(packetid int, logicNo uint32, data []byte) bool + FireSessionIdle func() bool + GetAttribute func(key interface{}) interface{} + GetSessionConfig func() *SessionConfig + IsIdle func() bool + LocalAddr func() string + RemoteAddr func() string + RemoveAttribute func(key interface{}) + Send func(packetid int, data interface{}, sync ...bool) bool + SendEx func(packetid int, logicNo uint32, data interface{}, sync bool) bool + SetAttribute func(key, value interface{}) bool + type NetEngine struct + func (e *NetEngine) Connect(sc *SessionConfig) error + func (e *NetEngine) GetAcceptors() []Acceptor + func (e *NetEngine) Init() + func (e *NetEngine) Listen(sc *SessionConfig) error + func (e *NetEngine) ModuleName() string + func (e *NetEngine) ShutConnector(ip string, port int) + func (e *NetEngine) Shutdown() + func (e *NetEngine) Update() + type NetLibParamError struct + Param string + Src string + func (self *NetLibParamError) Error() string + type NilEncDecoder struct + func (this *NilEncDecoder) Marshal(pack interface{}) ([]byte, error) + func (this *NilEncDecoder) Unmarshal(buf []byte, pack interface{}) error + type PacketCutSlicesFunc func(data []byte) (int, []interface{}) + type PacketFactory interface + CreatePacket func() interface{} + type PacketFactoryWrapper func() interface + func (pfw PacketFactoryWrapper) CreatePacket() interface{} + type PacketHeader struct + EncodeType int16 + PacketId int16 + type PacketPool struct + func NewPacketPool(num int) *PacketPool + func (pp *PacketPool) Get() (p *packet) + func (pp *PacketPool) Give(p *packet) + type ProtoHeader struct + Len uint16 + LogicNo uint32 + Seq uint16 + type ProtocolDecoder interface + Decode func(s *Session, r io.Reader) (packetid int, logicNo uint32, packet interface{}, err error, raw []byte) + FinishDecode func(s *Session) + func GetProtocolDecoder(name string) ProtocolDecoder + type ProtocolEncoder interface + Encode func(s *Session, packetid int, logicNo uint32, packet interface{}, w io.Writer) (data []byte, err error) + FinishEncode func(s *Session) + func GetProtocolEncoder(name string) ProtocolEncoder + type RWBuffer struct + func AllocRWBuf() *RWBuffer + func (rwb *RWBuffer) Init() + type ServerInfo struct + AreaID int + Banner []string + Data string + Id int + Name string + Type int + type ServiceStats struct + Addr string + Id int + MaxActive int + MaxDone int + Name string + RunningTime int64 + SessionStats []SessionStats + Type int + type Session struct + Auth bool + GroupId int + Id int + PendingRcv bool + PendingSnd bool + Sid int64 + func (s *Session) Close() + func (s *Session) FireConnectEvent() bool + func (s *Session) FireDisconnectEvent() bool + func (s *Session) FirePacketReceived(packetid int, logicNo uint32, packet interface{}) bool + func (s *Session) FirePacketSent(packetid int, logicNo uint32, data []byte) bool + func (s *Session) FireSessionIdle() bool + func (s *Session) GetAttribute(key interface{}) interface{} + func (s *Session) GetSessionConfig() *SessionConfig + func (s *Session) IsConned() bool + func (s *Session) IsIdle() bool + func (s *Session) LocalAddr() string + func (s *Session) RemoteAddr() string + func (s *Session) RemoveAttribute(key interface{}) + func (s *Session) Send(packetid int, data interface{}, sync ...bool) bool + func (s *Session) SendEx(packetid int, logicNo uint32, data interface{}, sync bool) bool + func (s *Session) SetAttribute(key, value interface{}) bool + type SessionCloseListener interface + type SessionConfig struct + AllowMultiConn bool + AreaId int + AuthKey string + CertFile string + DecoderName string + EncoderName string + ErrorPacketHandlerName string + ExtraConn int + FilterChain []string + HandlerChain []string + Id int + IdleTimeout time.Duration + Ip string + IsAutoReconn bool + IsClient bool + IsInnerLink bool + KeepAlive bool + KeepAliveCount int + KeepAliveIdle time.Duration + KeepAlivePeriod time.Duration + KeyFile string + MTU int + MaxConn int + MaxDone int + MaxPacket int + MaxPend int + Name string + NoDelay bool + OuterIp string + Path string + Port int + Protocol string + RcvBuff int + ReadTimeout time.Duration + SndBuff int + SoLinger int + SupportFragment bool + Type int + WriteTimeout time.Duration + func (sc *SessionConfig) GetFilter(name string) SessionFilter + func (sc *SessionConfig) GetHandler(name string) SessionHandler + func (sc *SessionConfig) Init() + type SessionCutPacketListener interface + type SessionFilter interface + GetInterestOps func() uint + GetName func() string + OnPacketReceived func(s *Session, packetid int, logicNo uint32, packet interface{}) bool + OnPacketSent func(s *Session, packetid int, logicNo uint32, data []byte) bool + OnSessionClosed func(s *Session) bool + OnSessionIdle func(s *Session) bool + OnSessionOpened func(s *Session) bool + type SessionFilterChain struct + func NewSessionFilterChain() *SessionFilterChain + func (sfc *SessionFilterChain) AddFirst(sf SessionFilter) + func (sfc *SessionFilterChain) AddLast(sf SessionFilter) + func (sfc *SessionFilterChain) GetFilter(name string) SessionFilter + func (sfc *SessionFilterChain) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) bool + func (sfc *SessionFilterChain) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) bool + func (sfc *SessionFilterChain) OnSessionClosed(s *Session) bool + func (sfc *SessionFilterChain) OnSessionIdle(s *Session) bool + func (sfc *SessionFilterChain) OnSessionOpened(s *Session) bool + type SessionFilterCreator func() SessionFilter + func GetSessionFilterCreator(name string) SessionFilterCreator + type SessionHandler interface + GetInterestOps func() uint + GetName func() string + OnPacketReceived func(s *Session, packetid int, logicNo uint32, packet interface{}) + OnPacketSent func(s *Session, packetid int, logicNo uint32, data []byte) + OnSessionClosed func(s *Session) + OnSessionIdle func(s *Session) + OnSessionOpened func(s *Session) + type SessionHandlerChain struct + func NewSessionHandlerChain() *SessionHandlerChain + func (shc *SessionHandlerChain) AddFirst(sh SessionHandler) + func (shc *SessionHandlerChain) AddLast(sh SessionHandler) + func (shc *SessionHandlerChain) GetHandler(name string) SessionHandler + func (shc *SessionHandlerChain) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) + func (shc *SessionHandlerChain) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) + func (shc *SessionHandlerChain) OnSessionClosed(s *Session) + func (shc *SessionHandlerChain) OnSessionIdle(s *Session) + func (shc *SessionHandlerChain) OnSessionOpened(s *Session) + type SessionHandlerCreator func() SessionHandler + func GetSessionHandlerCreator(name string) SessionHandlerCreator + type SessionStats struct + GroupId int + Id int + PendRecvPack int + PendSendPack int + RecvedBytes int64 + RecvedPack int64 + RemoteAddr string + RunningTime int64 + SendedBytes int64 + SendedPack int64 + type TcpAcceptor struct + func (a *TcpAcceptor) Addr() net.Addr + func (a *TcpAcceptor) GetSessionConfig() *SessionConfig + type TcpConnector struct + func (c *TcpConnector) GetSessionConfig() *SessionConfig + type TcpSession struct + func (s *TcpSession) LocalAddr() string + func (s *TcpSession) RemoteAddr() string + type TypeTester func(pack interface{}) int + type UdpAcceptor struct + func (a *UdpAcceptor) Addr() net.Addr + func (a *UdpAcceptor) GetSessionConfig() *SessionConfig + type UdpConnector struct + func (c *UdpConnector) GetSessionConfig() *SessionConfig + type UdpSession struct + func (s *UdpSession) LocalAddr() string + func (s *UdpSession) RemoteAddr() string + type UnparsePacketTypeErr struct + EncodeType int16 + Err error + PacketId int16 + func NewUnparsePacketTypeErr(et, packid int16, err error) *UnparsePacketTypeErr + func (this *UnparsePacketTypeErr) Error() string + type WsAcceptor struct + func (a *WsAcceptor) Addr() net.Addr + func (a *WsAcceptor) GetSessionConfig() *SessionConfig + type WsAddr struct + func (a *WsAddr) Network() string + func (a *WsAddr) String() string + type WsConnector struct + func (c *WsConnector) GetSessionConfig() *SessionConfig + type WsSession struct + func (s *WsSession) LocalAddr() string + func (s *WsSession) RemoteAddr() string