netlib

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

config

protocol

binary

Gbp

Gob

nil

encoding

error

handler

session

acceptor

connector

session

acceptor

connector

session

connector

Index

Constants

View Source
const (
	EncodingTypeNil = iota
	EncodingTypeGPB
	EncodingTypeBinary
	EncodingTypeGob
	EncodingTypeMax
)
View Source
const (
	InterestOps_Opened uint = iota
	InterestOps_Closed
	InterestOps_Idle
	InterestOps_Received
	InterestOps_Sent
	InterestOps_Max
)
View Source
const (
	DefaultMaxConnect = 1024
)
View Source
const (
	IoServiceMaxCount int = 10
)
View Source
const (
	RWBufRecyclerBacklog int = 128
)
View Source
const (
	ReconnectInterval time.Duration = 5 * time.Second
)

Variables

View Source
var (
	DefaultProtocoDecoderName = "default-protocol-decoder"

	ErrRcvBufCannotGet = errors.New("Session rcvbuf get failed")
)
View Source
var (
	LenOfPacketHeader int
	LenOfProtoHeader  int
	MaxPacketSize     int = 64 * 1024
)
View Source
var (
	DefaultProtocolEncoderName    = "default-protocol-encoder"
	DefaultBuiltinProtocolEncoder = &DefaultProtocolEncoder{}

	ErrSndBufCannotGet     = errors.New("Session sndbuf get failed")
	ErrExceedMaxPacketSize = errors.New("exceed max packet size")
)
View Source
var Config = Configuration{}
View Source
var (
	ConnectorMgr = &connectorMgr{
		pool: make(map[string]Connector),
	}
)
View Source
var ErrSendBufFull = errors.New("sendbuf is full")
View Source
var ErrShutdown = errors.New("connection is shut down")
View Source
var ErrUnsupportRpc = errors.New("only inner session support rpc")
View Source
var ErrorTypeNotFit = errors.New("packet not proto.Message type")
View Source
var Gob = &GobEncDecoder{}
View Source
var Gpb = &GbpEncDecoder{}
View Source
var (
	NetModule = newNetEngine()
)
View Source
var Nil = &NilEncDecoder{}
View Source
var RWRecycler = recycler.NewRecycler(
	RWBufRecyclerBacklog,
	func() interface{} {
		rb := &RWBuffer{
			buf: make([]byte, 0, MaxPacketSize),
		}

		return rb
	},
	"rwbuf_recycler",
)
View Source
var (
	SendRoutinePoison *packet = nil
)

Functions

func AllocAction

func AllocAction() *action

func AllocPacket

func AllocPacket() *packet

func BenchmarkAllocAction

func BenchmarkAllocAction(b *testing.B)

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 FreeRWBuf

func FreeRWBuf(buf *RWBuffer)

func GetPacketTypeAndId

func GetPacketTypeAndId(pack interface{}) (int, int)

func Listen

func Listen(sc *SessionConfig) error

func MarshalPacket

func MarshalPacket(packetid int, pack interface{}) ([]byte, error)

func MarshalPacketNoPackId

func MarshalPacketNoPackId(pack interface{}) (data []byte, err error)

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 Register

func Register(mainId int, msgType interface{}, h func(session *Session, packetId int, data interface{}) error)

func Register1ToMHandler

func Register1ToMHandler(h Handler, packetIds ...int)

func RegisterFactory

func RegisterFactory(packetId int, factory PacketFactory)

func RegisterHandler

func RegisterHandler(packetId int, h Handler)

func RegisterRangeHandler

func RegisterRangeHandler(start, end int, h Handler)

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

func RegisterRpcName(name string, rcvr interface{}) error

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 ShutConnector(ip string, port int)

func SkipHeaderGetRaw

func SkipHeaderGetRaw(data []byte) []byte

func Stats

func Stats() map[int]ServiceStats

func TestAllocAction

func TestAllocAction(t *testing.T)

func TestFreeAction

func TestFreeAction(t *testing.T)

func UnmarshalPacket

func UnmarshalPacket(data []byte) (int, interface{}, error)

func UnmarshalPacketNoPackId

func UnmarshalPacketNoPackId(data []byte, pck interface{}) error

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 (bsf *BasicSessionFilter) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) bool

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) Decode

func (pdi *DefaultProtocolDecoder) Decode(s *Session, r io.Reader) (packetid int, logicNo uint32, packet interface{}, err error, raw []byte)

func (*DefaultProtocolDecoder) FinishDecode

func (pdi *DefaultProtocolDecoder) FinishDecode(s *Session)

type DefaultProtocolEncoder

type DefaultProtocolEncoder struct {
	PacketCutor PacketCutSlicesFunc
}

func (*DefaultProtocolEncoder) CutAndSendPacket

func (dec *DefaultProtocolEncoder) CutAndSendPacket(s *Session, logicNo uint32, data []byte, w io.Writer) (err error)

func (*DefaultProtocolEncoder) Encode

func (dec *DefaultProtocolEncoder) Encode(s *Session, packetid int, logicNo uint32, packet interface{}, w io.Writer) (data []byte, err error)

func (*DefaultProtocolEncoder) FinishEncode

func (dec *DefaultProtocolEncoder) FinishEncode(s *Session)

type EncDecoder

type EncDecoder interface {
	Unmarshal(buf []byte, pack interface{}) error
	Marshal(pack interface{}) ([]byte, error)
}

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

type Handler interface {
	Process(session *Session, packetid int, data interface{}) error
}

func GetHandler

func GetHandler(packetId int) Handler

type HandlerWrapper

type HandlerWrapper func(session *Session, packetid int, data interface{}) error

func (HandlerWrapper) Process

func (hw HandlerWrapper) Process(session *Session, packetid int, data interface{}) error

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 (e *NetEngine) GetAcceptors() []Acceptor

func (*NetEngine) Init

func (e *NetEngine) Init()

func (*NetEngine) Listen

func (e *NetEngine) Listen(sc *SessionConfig) error

func (*NetEngine) ModuleName

func (e *NetEngine) ModuleName() string

////////////////////////////////////////////////////////////////// / Module Implement [beg] //////////////////////////////////////////////////////////////////

func (*NetEngine) ShutConnector

func (e *NetEngine) ShutConnector(ip string, port int)

func (*NetEngine) Shutdown

func (e *NetEngine) Shutdown()

func (*NetEngine) Update

func (e *NetEngine) Update()

type NetLibParamError

type NetLibParamError struct {
	Src   string
	Param string
}

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 PacketCutSlicesFunc func(data []byte) (int, []interface{})

type PacketFactory

type PacketFactory interface {
	CreatePacket() interface{}
}

type PacketFactoryWrapper

type PacketFactoryWrapper func() interface{}

func (PacketFactoryWrapper) CreatePacket

func (pfw PacketFactoryWrapper) CreatePacket() interface{}

type PacketHeader

type PacketHeader struct {
	EncodeType int16
	PacketId   int16
}

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 ProtoHeader struct {
	Len     uint16 //包长度
	Seq     uint16 //包序号
	LogicNo uint32 //逻辑号
}

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

func (*RWBuffer) Init

func (rwb *RWBuffer) Init()

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 ServerInfo struct {
	Name   string
	Type   int
	Id     int
	AreaID int
	Data   string
	Banner []string
}

type ServiceStats

type ServiceStats struct {
	Id           int
	Type         int
	Name         string
	Addr         string
	MaxActive    int
	MaxDone      int
	RunningTime  int64
	SessionStats []SessionStats
}

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

func (s *Session) CallRpc(serviceMethod string, args interface{}, reply interface{}) error

Call invokes the named function, waits for it to complete, and returns its error status.

func (*Session) Close

func (s *Session) Close()

func (*Session) FireConnectEvent

func (s *Session) FireConnectEvent() bool

func (*Session) FireDisconnectEvent

func (s *Session) FireDisconnectEvent() bool

func (*Session) FirePacketReceived

func (s *Session) FirePacketReceived(packetid int, logicNo uint32, packet interface{}) bool

func (*Session) FirePacketSent

func (s *Session) FirePacketSent(packetid int, logicNo uint32, data []byte) bool

func (*Session) FireSessionIdle

func (s *Session) FireSessionIdle() bool

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) IsConned

func (s *Session) IsConned() bool

func (*Session) IsIdle

func (s *Session) IsIdle() bool

func (*Session) LocalAddr

func (s *Session) LocalAddr() string

func (*Session) RemoteAddr

func (s *Session) RemoteAddr() string

func (*Session) RemoveAttribute

func (s *Session) RemoveAttribute(key interface{})

func (*Session) Send

func (s *Session) Send(packetid int, data interface{}, sync ...bool) bool

func (*Session) SendEx

func (s *Session) SendEx(packetid int, logicNo uint32, data interface{}, sync bool) bool

func (*Session) SetAttribute

func (s *Session) SetAttribute(key, value interface{}) bool

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 (sfc *SessionFilterChain) OnPacketSent(s *Session, packetid int, logicNo uint32, data []byte) bool

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 SessionStats struct {
	Id           int
	GroupId      int
	RunningTime  int64
	SendedBytes  int64
	RecvedBytes  int64
	SendedPack   int64
	RecvedPack   int64
	PendSendPack int
	PendRecvPack int
	RemoteAddr   string
}

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 UnknowPacketHandler interface {
	OnUnknowPacket(s *Session, packetid int, logicNo uint32, data []byte) bool //run in session receive goroutine
}

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

func (hw UnknowPacketHandlerWrapper) OnUnknowPacket(session *Session, packetid int, logicNo uint32, data []byte) bool

type UnparsePacketTypeErr

type UnparsePacketTypeErr struct {
	EncodeType int16
	PacketId   int16
	Err        error
}

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 WsAddr

type WsAddr struct {
	// contains filtered or unexported fields
}

func (*WsAddr) Network

func (a *WsAddr) Network() string

name of the network

func (*WsAddr) String

func (a *WsAddr) String() string

string form of address

type WsConnector

type WsConnector struct {
	// contains filtered or unexported fields
}

func (*WsConnector) GetSessionConfig

func (c *WsConnector) GetSessionConfig() *SessionConfig

type WsSession

type WsSession struct {
	Session
	// contains filtered or unexported fields
}

func (*WsSession) LocalAddr

func (s *WsSession) LocalAddr() string

func (*WsSession) RemoteAddr

func (s *WsSession) RemoteAddr() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL