Documentation ¶
Overview ¶
config
protocol
binary
Gbp ¶
Gob ¶
nil
encoding
error
handler
session
acceptor
connector
session
acceptor
connector
session
connector
Index ¶
- Constants
- Variables
- 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 RegisteProtocolDecoder(name string, dec ProtocolDecoder)
- func RegisteProtocolEncoder(name string, enc ProtocolEncoder)
- func RegisteSessionFilterCreator(filterName string, sfc SessionFilterCreator)
- func RegisteSessionHandlerCreator(name string, shc SessionHandlerCreator)
- func RegisteUnknowPacketHandlerCreator(name string, ephc UnknowPacketHandlerCreator)
- 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 RegisterRpc(rcvr interface{}) error
- func RegisterRpcName(name string, rcvr interface{}) error
- func SendStartNetIoService(sc *SessionConfig) bool
- func ShutConnector(ip string, port int)
- func SkipHeaderGetRaw(data []byte) []byte
- 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
- type ActionPool
- type BasicSessionFilter
- func (bsf *BasicSessionFilter) GetInterestOps() uint
- func (bsf *BasicSessionFilter) GetName() string
- func (bsf *BasicSessionFilter) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) bool
- func (bsf *BasicSessionFilter) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) bool
- func (bsf *BasicSessionFilter) OnSessionClosed(s *Session) bool
- func (bsf *BasicSessionFilter) OnSessionIdle(s *Session) bool
- func (bsf *BasicSessionFilter) OnSessionOpened(s *Session) bool
- type BasicSessionHandler
- func (bsh *BasicSessionHandler) GetInterestOps() uint
- func (bsh *BasicSessionHandler) GetName() string
- 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
- type Call
- type Configuration
- type Connector
- type DefaultProtocolDecoder
- type DefaultProtocolEncoder
- 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
- type GbpEncDecoder
- type GobEncDecoder
- type Handler
- type HandlerWrapper
- type ISession
- type NetEngine
- 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
- type NilEncDecoder
- type PacketCutSlicesFunc
- type PacketFactory
- type PacketFactoryWrapper
- type PacketHeader
- type PacketPool
- type ProtoHeader
- type ProtocolDecoder
- type ProtocolEncoder
- type RWBuffer
- type ServerError
- type ServerInfo
- type ServiceStats
- type Session
- func (s *Session) CallRpc(serviceMethod string, args interface{}, reply interface{}) error
- 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) GoRpc(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
- 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
- type SessionConfig
- type SessionCutPacketListener
- type SessionFilter
- type 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
- type SessionHandler
- type 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
- type SessionStats
- type TcpAcceptor
- type TcpConnector
- type TcpSession
- type TypeTester
- type UdpAcceptor
- type UdpConnector
- type UdpSession
- type UnknowPacketHandler
- type UnknowPacketHandlerCreator
- type UnknowPacketHandlerWrapper
- type UnparsePacketTypeErr
- type WsAcceptor
- type WsAddr
- type WsConnector
- type WsSession
Constants ¶
const ( EncodingTypeNil = iota EncodingTypeGPB EncodingTypeBinary EncodingTypeGob EncodingTypeMax )
const ( InterestOps_Opened uint = iota InterestOps_Closed InterestOps_Idle InterestOps_Received InterestOps_Sent InterestOps_Max )
const (
DefaultMaxConnect = 1024
)
const (
IoServiceMaxCount int = 10
)
const (
RWBufRecyclerBacklog int = 128
)
const (
ReconnectInterval time.Duration = 5 * time.Second
)
Variables ¶
var ( DefaultProtocoDecoderName = "default-protocol-decoder" ErrRcvBufCannotGet = errors.New("Session rcvbuf get failed") )
var ( LenOfPacketHeader int LenOfProtoHeader int MaxPacketSize int = 64 * 1024 )
var ( DefaultProtocolEncoderName = "default-protocol-encoder" DefaultBuiltinProtocolEncoder = &DefaultProtocolEncoder{} ErrSndBufCannotGet = errors.New("Session sndbuf get failed") ErrExceedMaxPacketSize = errors.New("exceed max packet size") )
var Bcd = &BinaryEncDecoder{}
var Config = Configuration{}
var ( ConnectorMgr = &connectorMgr{ pool: make(map[string]Connector), } )
var ErrSendBufFull = errors.New("sendbuf is full")
var ErrShutdown = errors.New("connection is shut down")
var ErrUnsupportRpc = errors.New("only inner session support rpc")
var ErrorTypeNotFit = errors.New("packet not proto.Message type")
var Gob = &GobEncDecoder{}
var Gpb = &GbpEncDecoder{}
var (
NetModule = newNetEngine()
)
var Nil = &NilEncDecoder{}
var RWRecycler = recycler.NewRecycler( RWBufRecyclerBacklog, func() interface{} { rb := &RWBuffer{ buf: make([]byte, 0, MaxPacketSize), } return rb }, "rwbuf_recycler", )
var (
SendRoutinePoison *packet = nil
)
Functions ¶
func AllocAction ¶
func AllocAction() *action
func AllocPacket ¶
func AllocPacket() *packet
func BenchmarkAllocAction ¶
func Connect ¶
func Connect(sc *SessionConfig) error
func CreatePacket ¶
func CreatePacket(packetId int) interface{}
func FreeAction ¶
func FreeAction(a *action)
func FreePacket ¶
func FreePacket(p *packet)
func GetPacketTypeAndId ¶
func Listen ¶
func Listen(sc *SessionConfig) error
func MarshalPacket ¶
func MarshalPacketNoPackId ¶
func RegisteEncoding ¶
func RegisteEncoding(edtype int, ed EncDecoder, tt TypeTester)
func RegisteProtocolDecoder ¶
func RegisteProtocolDecoder(name string, dec ProtocolDecoder)
func RegisteProtocolEncoder ¶
func RegisteProtocolEncoder(name string, enc ProtocolEncoder)
func RegisteSessionFilterCreator ¶
func RegisteSessionFilterCreator(filterName string, sfc SessionFilterCreator)
func RegisteSessionHandlerCreator ¶
func RegisteSessionHandlerCreator(name string, shc SessionHandlerCreator)
func RegisteUnknowPacketHandlerCreator ¶
func RegisteUnknowPacketHandlerCreator(name string, ephc UnknowPacketHandlerCreator)
func Register1ToMHandler ¶
func RegisterFactory ¶
func RegisterFactory(packetId int, factory PacketFactory)
func RegisterHandler ¶
func RegisterRangeHandler ¶
func RegisterRpc ¶
func RegisterRpc(rcvr interface{}) error
Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:
- exported method of exported type
- two arguments, both of exported type
- the second argument is a pointer
- one return value, of type error
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func RegisterRpcName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func SendStartNetIoService ¶
func SendStartNetIoService(sc *SessionConfig) bool
func ShutConnector ¶
func SkipHeaderGetRaw ¶
func Stats ¶
func Stats() map[int]ServiceStats
func TestAllocAction ¶
func TestFreeAction ¶
func UnmarshalPacket ¶
func UnmarshalPacketNoPackId ¶
Types ¶
type Acceptor ¶
type Acceptor interface { GetSessionConfig() *SessionConfig Addr() net.Addr // contains filtered or unexported methods }
func GetAcceptors ¶
func GetAcceptors() []Acceptor
type ActionPool ¶
type ActionPool struct {
// contains filtered or unexported fields
}
func NewActionPool ¶
func NewActionPool(num int) *ActionPool
func (*ActionPool) Get ¶
func (ap *ActionPool) Get() (a *action)
func (*ActionPool) Give ¶
func (ap *ActionPool) Give(a *action)
type BasicSessionFilter ¶
type BasicSessionFilter struct { }
func (*BasicSessionFilter) GetInterestOps ¶
func (bsf *BasicSessionFilter) GetInterestOps() uint
func (*BasicSessionFilter) GetName ¶
func (bsf *BasicSessionFilter) GetName() string
func (*BasicSessionFilter) OnPacketReceived ¶
func (bsf *BasicSessionFilter) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) bool
func (*BasicSessionFilter) OnPacketSent ¶
func (*BasicSessionFilter) OnSessionClosed ¶
func (bsf *BasicSessionFilter) OnSessionClosed(s *Session) bool
func (*BasicSessionFilter) OnSessionIdle ¶
func (bsf *BasicSessionFilter) OnSessionIdle(s *Session) bool
func (*BasicSessionFilter) OnSessionOpened ¶
func (bsf *BasicSessionFilter) OnSessionOpened(s *Session) bool
type BasicSessionHandler ¶
type BasicSessionHandler struct { }
func (*BasicSessionHandler) GetInterestOps ¶
func (bsh *BasicSessionHandler) GetInterestOps() uint
func (*BasicSessionHandler) GetName ¶
func (bsh *BasicSessionHandler) GetName() string
func (*BasicSessionHandler) OnPacketReceived ¶
func (bsh *BasicSessionHandler) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{})
func (*BasicSessionHandler) OnPacketSent ¶
func (bsh *BasicSessionHandler) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte)
func (*BasicSessionHandler) OnSessionClosed ¶
func (bsh *BasicSessionHandler) OnSessionClosed(s *Session)
func (*BasicSessionHandler) OnSessionIdle ¶
func (bsh *BasicSessionHandler) OnSessionIdle(s *Session)
func (*BasicSessionHandler) OnSessionOpened ¶
func (bsh *BasicSessionHandler) OnSessionOpened(s *Session)
type BinaryEncDecoder ¶
type BinaryEncDecoder struct { }
func (*BinaryEncDecoder) Marshal ¶
func (this *BinaryEncDecoder) Marshal(pack interface{}) ([]byte, error)
func (*BinaryEncDecoder) Unmarshal ¶
func (this *BinaryEncDecoder) Unmarshal(buf []byte, pack interface{}) error
type Call ¶
type Call struct { ServiceMethod string // The name of the service and method to call. Args interface{} // The argument to the function (*struct). Reply interface{} // The reply from the function (*struct). Error error // After completion, the error status. Done chan *Call // Receives *Call when Go is complete. }
Call represents an active RPC.
type Configuration ¶
type Configuration struct { SrvInfo ServerInfo IoServices []SessionConfig }
func (*Configuration) Close ¶
func (c *Configuration) Close() error
func (*Configuration) Init ¶
func (c *Configuration) Init() error
func (*Configuration) Name ¶
func (c *Configuration) Name() string
type Connector ¶
type Connector interface { GetSessionConfig() *SessionConfig // contains filtered or unexported methods }
type DefaultProtocolDecoder ¶
type DefaultProtocolDecoder struct { }
func (*DefaultProtocolDecoder) FinishDecode ¶
func (pdi *DefaultProtocolDecoder) FinishDecode(s *Session)
type DefaultProtocolEncoder ¶
type DefaultProtocolEncoder struct {
PacketCutor PacketCutSlicesFunc
}
func (*DefaultProtocolEncoder) CutAndSendPacket ¶
func (*DefaultProtocolEncoder) FinishEncode ¶
func (dec *DefaultProtocolEncoder) FinishEncode(s *Session)
type EncDecoder ¶
type GbpEncDecoder ¶
type GbpEncDecoder struct { }
func (*GbpEncDecoder) Marshal ¶
func (this *GbpEncDecoder) Marshal(pack interface{}) ([]byte, error)
func (*GbpEncDecoder) Unmarshal ¶
func (this *GbpEncDecoder) Unmarshal(buf []byte, pack interface{}) error
type GobEncDecoder ¶
type GobEncDecoder struct { }
func (*GobEncDecoder) Marshal ¶
func (this *GobEncDecoder) Marshal(pack interface{}) ([]byte, error)
func (*GobEncDecoder) Unmarshal ¶
func (this *GobEncDecoder) Unmarshal(buf []byte, pack interface{}) error
type Handler ¶
func GetHandler ¶
type HandlerWrapper ¶
type ISession ¶
type ISession interface { SetAttribute(key, value interface{}) bool RemoveAttribute(key interface{}) GetAttribute(key interface{}) interface{} GetSessionConfig() *SessionConfig LocalAddr() string RemoteAddr() string IsIdle() bool Close() Send(packetid int, data interface{}, sync ...bool) bool SendEx(packetid int, logicNo uint32, data interface{}, sync bool) bool FireConnectEvent() bool FireDisconnectEvent() bool FirePacketReceived(packetid int, logicNo uint32, packet interface{}) bool FirePacketSent(packetid int, logicNo uint32, data []byte) bool FireSessionIdle() bool }
type NetEngine ¶
type NetEngine struct {
// contains filtered or unexported fields
}
func (*NetEngine) Connect ¶
func (e *NetEngine) Connect(sc *SessionConfig) error
func (*NetEngine) GetAcceptors ¶
func (*NetEngine) Listen ¶
func (e *NetEngine) Listen(sc *SessionConfig) error
func (*NetEngine) ModuleName ¶
////////////////////////////////////////////////////////////////// / Module Implement [beg] //////////////////////////////////////////////////////////////////
func (*NetEngine) ShutConnector ¶
type NetLibParamError ¶
func (*NetLibParamError) Error ¶
func (self *NetLibParamError) Error() string
type NilEncDecoder ¶
type NilEncDecoder struct { }
func (*NilEncDecoder) Marshal ¶
func (this *NilEncDecoder) Marshal(pack interface{}) ([]byte, error)
func (*NilEncDecoder) Unmarshal ¶
func (this *NilEncDecoder) Unmarshal(buf []byte, pack interface{}) error
type PacketCutSlicesFunc ¶
type PacketFactory ¶
type PacketFactory interface {
CreatePacket() interface{}
}
type PacketFactoryWrapper ¶
type PacketFactoryWrapper func() interface{}
func (PacketFactoryWrapper) CreatePacket ¶
func (pfw PacketFactoryWrapper) CreatePacket() interface{}
type PacketHeader ¶
type PacketPool ¶
type PacketPool struct {
// contains filtered or unexported fields
}
func NewPacketPool ¶
func NewPacketPool(num int) *PacketPool
func (*PacketPool) Get ¶
func (pp *PacketPool) Get() (p *packet)
func (*PacketPool) Give ¶
func (pp *PacketPool) Give(p *packet)
type ProtoHeader ¶
type ProtocolDecoder ¶
type ProtocolDecoder interface { Decode(s *Session, r io.Reader) (packetid int, logicNo uint32, packet interface{}, err error, raw []byte) FinishDecode(s *Session) }
func GetProtocolDecoder ¶
func GetProtocolDecoder(name string) ProtocolDecoder
type ProtocolEncoder ¶
type ProtocolEncoder interface { Encode(s *Session, packetid int, logicNo uint32, packet interface{}, w io.Writer) (data []byte, err error) FinishEncode(s *Session) }
func GetProtocolEncoder ¶
func GetProtocolEncoder(name string) ProtocolEncoder
type RWBuffer ¶
type RWBuffer struct {
// contains filtered or unexported fields
}
func AllocRWBuf ¶
func AllocRWBuf() *RWBuffer
type ServerError ¶
type ServerError string
ServerError represents an error that has been returned from the remote side of the RPC connection.
func (ServerError) Error ¶
func (e ServerError) Error() string
type ServerInfo ¶
type ServiceStats ¶
type Session ¶
type Session struct { Id int GroupId int Sid int64 Auth bool PendingRcv bool PendingSnd bool // contains filtered or unexported fields }
func (*Session) CallRpc ¶
Call invokes the named function, waits for it to complete, and returns its error status.
func (*Session) FireConnectEvent ¶
func (*Session) FireDisconnectEvent ¶
func (*Session) FirePacketReceived ¶
func (*Session) FirePacketSent ¶
func (*Session) FireSessionIdle ¶
func (*Session) GetAttribute ¶
func (s *Session) GetAttribute(key interface{}) interface{}
func (*Session) GetSessionConfig ¶
func (s *Session) GetSessionConfig() *SessionConfig
func (*Session) GoRpc ¶
func (s *Session) GoRpc(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
Go invokes the function asynchronously. It returns the Call structure representing the invocation. The done channel will signal when the call is complete by returning the same Call object. If done is nil, Go will allocate a new channel. If non-nil, done must be buffered or Go will deliberately crash.
func (*Session) RemoteAddr ¶
func (*Session) RemoveAttribute ¶
func (s *Session) RemoveAttribute(key interface{})
func (*Session) SetAttribute ¶
type SessionCloseListener ¶
type SessionCloseListener interface {
// contains filtered or unexported methods
}
type SessionConfig ¶
type SessionConfig struct { Id int Type int AreaId int Protocol string //"tcp" "ws" "wss" Name string Ip string Path string //path of "ws" CertFile string KeyFile string OuterIp string //对外的IP Port int MaxDone int MaxPend int MaxPacket int MaxConn int ExtraConn int RcvBuff int SndBuff int SoLinger int MTU int WriteTimeout time.Duration ReadTimeout time.Duration IdleTimeout time.Duration KeepAlive bool KeepAlivePeriod time.Duration KeepAliveIdle time.Duration KeepAliveCount int NoDelay bool IsClient bool IsAutoReconn bool IsInnerLink bool AuthKey string //Authentication Key EncoderName string //ProtocolEncoder name DecoderName string //ProtocolDecoder name UnknowPacketHandlerName string FilterChain []string HandlerChain []string SupportFragment bool AllowMultiConn bool // contains filtered or unexported fields }
func (*SessionConfig) GetFilter ¶
func (sc *SessionConfig) GetFilter(name string) SessionFilter
func (*SessionConfig) GetHandler ¶
func (sc *SessionConfig) GetHandler(name string) SessionHandler
func (*SessionConfig) Init ¶
func (sc *SessionConfig) Init()
type SessionCutPacketListener ¶
type SessionCutPacketListener interface {
// contains filtered or unexported methods
}
type SessionFilter ¶
type SessionFilter interface { GetName() string GetInterestOps() uint OnSessionOpened(s *Session) bool //run in main goroutine OnSessionClosed(s *Session) bool //run in main goroutine OnSessionIdle(s *Session) bool //run in main goroutine OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) bool //run in session receive goroutine OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) bool //run in session send goroutine }
type SessionFilterChain ¶
type SessionFilterChain struct {
// contains filtered or unexported fields
}
func NewSessionFilterChain ¶
func NewSessionFilterChain() *SessionFilterChain
func (*SessionFilterChain) AddFirst ¶
func (sfc *SessionFilterChain) AddFirst(sf SessionFilter)
func (*SessionFilterChain) AddLast ¶
func (sfc *SessionFilterChain) AddLast(sf SessionFilter)
func (*SessionFilterChain) GetFilter ¶
func (sfc *SessionFilterChain) GetFilter(name string) SessionFilter
func (*SessionFilterChain) OnPacketReceived ¶
func (sfc *SessionFilterChain) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) bool
func (*SessionFilterChain) OnPacketSent ¶
func (*SessionFilterChain) OnSessionClosed ¶
func (sfc *SessionFilterChain) OnSessionClosed(s *Session) bool
func (*SessionFilterChain) OnSessionIdle ¶
func (sfc *SessionFilterChain) OnSessionIdle(s *Session) bool
func (*SessionFilterChain) OnSessionOpened ¶
func (sfc *SessionFilterChain) OnSessionOpened(s *Session) bool
type SessionFilterCreator ¶
type SessionFilterCreator func() SessionFilter
func GetSessionFilterCreator ¶
func GetSessionFilterCreator(name string) SessionFilterCreator
type SessionHandler ¶
type SessionHandler interface { GetName() string GetInterestOps() uint OnSessionOpened(s *Session) //run in main goroutine OnSessionClosed(s *Session) //run in main goroutine OnSessionIdle(s *Session) //run in main goroutine OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{}) //run in session receive goroutine OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) //run in session send goroutine }
type SessionHandlerChain ¶
type SessionHandlerChain struct {
// contains filtered or unexported fields
}
func NewSessionHandlerChain ¶
func NewSessionHandlerChain() *SessionHandlerChain
func (*SessionHandlerChain) AddFirst ¶
func (shc *SessionHandlerChain) AddFirst(sh SessionHandler)
func (*SessionHandlerChain) AddLast ¶
func (shc *SessionHandlerChain) AddLast(sh SessionHandler)
func (*SessionHandlerChain) GetHandler ¶
func (shc *SessionHandlerChain) GetHandler(name string) SessionHandler
func (*SessionHandlerChain) OnPacketReceived ¶
func (shc *SessionHandlerChain) OnPacketReceived(s *Session, packetid int, logicNo uint32, packet interface{})
func (*SessionHandlerChain) OnPacketSent ¶
func (shc *SessionHandlerChain) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte)
func (*SessionHandlerChain) OnSessionClosed ¶
func (shc *SessionHandlerChain) OnSessionClosed(s *Session)
func (*SessionHandlerChain) OnSessionIdle ¶
func (shc *SessionHandlerChain) OnSessionIdle(s *Session)
func (*SessionHandlerChain) OnSessionOpened ¶
func (shc *SessionHandlerChain) OnSessionOpened(s *Session)
type SessionHandlerCreator ¶
type SessionHandlerCreator func() SessionHandler
func GetSessionHandlerCreator ¶
func GetSessionHandlerCreator(name string) SessionHandlerCreator
type SessionStats ¶
type TcpAcceptor ¶
type TcpAcceptor struct {
// contains filtered or unexported fields
}
func (*TcpAcceptor) Addr ¶
func (a *TcpAcceptor) Addr() net.Addr
func (*TcpAcceptor) GetSessionConfig ¶
func (a *TcpAcceptor) GetSessionConfig() *SessionConfig
type TcpConnector ¶
type TcpConnector struct {
// contains filtered or unexported fields
}
func (*TcpConnector) GetSessionConfig ¶
func (c *TcpConnector) GetSessionConfig() *SessionConfig
type TcpSession ¶
type TcpSession struct { Session // contains filtered or unexported fields }
func (*TcpSession) LocalAddr ¶
func (s *TcpSession) LocalAddr() string
func (*TcpSession) RemoteAddr ¶
func (s *TcpSession) RemoteAddr() string
type TypeTester ¶
type TypeTester func(pack interface{}) int
type UdpAcceptor ¶
type UdpAcceptor struct {
// contains filtered or unexported fields
}
func (*UdpAcceptor) Addr ¶
func (a *UdpAcceptor) Addr() net.Addr
func (*UdpAcceptor) GetSessionConfig ¶
func (a *UdpAcceptor) GetSessionConfig() *SessionConfig
type UdpConnector ¶
type UdpConnector struct {
// contains filtered or unexported fields
}
func (*UdpConnector) GetSessionConfig ¶
func (c *UdpConnector) GetSessionConfig() *SessionConfig
type UdpSession ¶
type UdpSession struct { Session // contains filtered or unexported fields }
func (*UdpSession) LocalAddr ¶
func (s *UdpSession) LocalAddr() string
func (*UdpSession) RemoteAddr ¶
func (s *UdpSession) RemoteAddr() string
type UnknowPacketHandler ¶
type UnknowPacketHandlerCreator ¶
type UnknowPacketHandlerCreator func() UnknowPacketHandler
func GetUnknowPacketHandlerCreator ¶
func GetUnknowPacketHandlerCreator(name string) UnknowPacketHandlerCreator
type UnknowPacketHandlerWrapper ¶
type UnknowPacketHandlerWrapper func(session *Session, packetid int, logicNo uint32, data []byte) bool
func (UnknowPacketHandlerWrapper) OnUnknowPacket ¶
type UnparsePacketTypeErr ¶
func NewUnparsePacketTypeErr ¶
func NewUnparsePacketTypeErr(et, packid int16, err error) *UnparsePacketTypeErr
func (*UnparsePacketTypeErr) Error ¶
func (this *UnparsePacketTypeErr) Error() string
type WsAcceptor ¶
type WsAcceptor struct {
// contains filtered or unexported fields
}
func (*WsAcceptor) Addr ¶
func (a *WsAcceptor) Addr() net.Addr
func (*WsAcceptor) GetSessionConfig ¶
func (a *WsAcceptor) GetSessionConfig() *SessionConfig
type WsConnector ¶
type WsConnector struct {
// contains filtered or unexported fields
}
func (*WsConnector) GetSessionConfig ¶
func (c *WsConnector) GetSessionConfig() *SessionConfig
Source Files ¶
- acceptor.go
- action.go
- command_start_ioservice.go
- config.go
- connector.go
- connectormgr.go
- decoder.go
- defaultprotocol.go
- enc-binary.go
- enc-gbp.go
- enc-gob.go
- enc-nill.go
- encoder.go
- encoding.go
- error.go
- ioservice.go
- netengine.go
- packetfactory.go
- packethandler.go
- packetpool.go
- recycler_action.go
- recycler_rwbuf.go
- rpc_client.go
- rpc_server.go
- session.go
- sessionfilter.go
- sessionhandler.go
- tcp_acceptor.go
- tcp_connector.go
- tcp_session.go
- test.go
- udp_acceptor.go
- udp_connector.go
- udp_session.go
- unknowpackethandler.go
- ws_acceptor.go
- ws_connector.go
- ws_session.go
Directories ¶
Path | Synopsis |
---|---|
Package tcpkeepalive implements additional TCP keepalive control beyond what is currently offered by the net pkg.
|
Package tcpkeepalive implements additional TCP keepalive control beyond what is currently offered by the net pkg. |