Documentation ¶
Index ¶
- Constants
- Variables
- func RpcMarshal(b []byte, val interface{}) []byte
- func RpcUnMarshal(b []byte) (interface{}, []byte)
- func Run()
- func UnixTS() int64
- type Agent
- type AgentID
- type BytesBuffer
- func (b *BytesBuffer) Count() int
- func (b *BytesBuffer) Read(n int)
- func (b *BytesBuffer) ReadBuf(n int) []byte
- func (b *BytesBuffer) Reserve(s int)
- func (b *BytesBuffer) Reset()
- func (b *BytesBuffer) Write(n int)
- func (b *BytesBuffer) WriteBuf() []byte
- func (b *BytesBuffer) WriteBytes(m []byte) int
- func (b *BytesBuffer) WriteUint32(i uint32) int
- func (b *BytesBuffer) WriteUint8(m byte) int
- type Component
- type ComponentID
- type ComponentType
- type ConnType
- type EventQueue
- type EventReceiver
- type ITcpClientMgr
- type ITcpServerMgr
- type ITranMsgMultiple
- type ITransportMsg
- type ITransporter
- type Linker
- type NetLinker
- type Option
- type OptionMgr
- type PingEventMsg
- type PingMgr
- type ProtoTypeID
- type ServerType
- type SessionHandler
- type SessionMgr
- type TcpClientMgr
- type TcpConn
- func (n *TcpConn) Close()
- func (n *TcpConn) Destroy()
- func (n *TcpConn) DoPing()
- func (n *TcpConn) DoPong(nowTick int64)
- func (n *TcpConn) GetID() AgentID
- func (n *TcpConn) GetOption() *TransportOption
- func (n *TcpConn) GetType() int16
- func (n *TcpConn) GetUserType() interface{}
- func (n *TcpConn) IsClosed() bool
- func (n *TcpConn) LocalAddr() net.Addr
- func (n *TcpConn) MultipleMsg() ITranMsgMultiple
- func (n *TcpConn) Ping() bool
- func (n *TcpConn) Pong(nowTick int64)
- func (n *TcpConn) ReadMsg() ([]byte, error)
- func (n *TcpConn) RemoteAddr() net.Addr
- func (n *TcpConn) RpcCall(msgID ProtoTypeID, b []byte) bool
- func (n *TcpConn) Run() error
- func (n *TcpConn) SetUserType(t interface{})
- func (n *TcpConn) WriteMsg(msgID ProtoTypeID, b []byte) bool
- type TcpServerMgr
- type TimerHandler
- type TimerManager
- type TransportMsgPack
- type TransportMultiple
- type TransportOption
Constants ¶
View Source
const ( PING_OP_TYPE_ADD_PING = iota PING_OP_TYPE_REMOVE_PING PING_OP_TYPE_DO_PONG )
View Source
const ( Linker_TCP_InComming = iota Linker_TCP_OutGoing )
View Source
const ( ConnType_TCP = iota ConnType_UDP )
View Source
const ( COMPONENT_TYPE_TCP_SERVER = component.COMPONENT_TYPE_TCP_SERVER COMPONENT_TYPE_TCP_CLIENT = component.COMPONENT_TYPE_TCP_CLIENT )
View Source
const ( MSG_KEY_LENGTH = 32 MSG_HEADER_LENGTH = 4 MSG_ID_LENGTH = 4 MSG_MAX_BODY_LENGTH = 8096 MSG_DEFAULT_BUF_LENGTH = 1024 MSG_DEFAULT_COUNT = 100 MSG_COUNT_CHECK_TIME = 3000 )
View Source
const BUFFER_BASE_SIZE = 1024
View Source
const KEEP_ALIVE_POLL_COUNT = 128
View Source
const TCP_ACCEPT_SLEEP = 150
Variables ¶
View Source
var ( //PINGTIME int64 = 5 * 1000 //Millisecond //PONGTIME int64 = PINGTIME * 2 CHECKTIME int64 = 256 //Millisecond )
Functions ¶
func RpcMarshal ¶
func RpcUnMarshal ¶
Types ¶
type BytesBuffer ¶
type BytesBuffer struct {
// contains filtered or unexported fields
}
func (*BytesBuffer) Count ¶
func (b *BytesBuffer) Count() int
func (*BytesBuffer) Read ¶
func (b *BytesBuffer) Read(n int)
func (*BytesBuffer) ReadBuf ¶
func (b *BytesBuffer) ReadBuf(n int) []byte
func (*BytesBuffer) Reserve ¶
func (b *BytesBuffer) Reserve(s int)
func (*BytesBuffer) Reset ¶
func (b *BytesBuffer) Reset()
func (*BytesBuffer) Write ¶
func (b *BytesBuffer) Write(n int)
func (*BytesBuffer) WriteBuf ¶
func (b *BytesBuffer) WriteBuf() []byte
func (*BytesBuffer) WriteBytes ¶
func (b *BytesBuffer) WriteBytes(m []byte) int
func (*BytesBuffer) WriteUint32 ¶
func (b *BytesBuffer) WriteUint32(i uint32) int
func (*BytesBuffer) WriteUint8 ¶
func (b *BytesBuffer) WriteUint8(m byte) int
type ComponentID ¶
type ComponentID = component.ComponentID
func GenComponentID ¶
func GenComponentID() ComponentID
type ComponentType ¶
type ComponentType = component.ComponentType
type EventQueue ¶
type EventQueue = event.EventQueue
type EventReceiver ¶
type EventReceiver = event.EventReceiver
type ITcpClientMgr ¶
type ITcpClientMgr interface { GetID() ComponentID GetType() ComponentType Connect(addr string, user_type interface{}) }
type ITcpServerMgr ¶
type ITcpServerMgr interface { GetID() ComponentID GetType() ComponentType Address() net.Addr }
type ITranMsgMultiple ¶
type ITranMsgMultiple interface { WriteMsg(ProtoTypeID, []byte) bool RpcCall(ProtoTypeID, []byte) bool Done() bool }
type ITransportMsg ¶
type ITransportMsg interface { GetType() byte // contains filtered or unexported methods }
type ITransporter ¶
type ITransporter interface { IsClosed() bool // contains filtered or unexported methods }
type Linker ¶
type Linker interface { GetID() AgentID Ping() bool DoPong(int64) GetOption() *TransportOption }
type NetLinker ¶
type NetLinker interface { GetID() AgentID Close() RemoteAddr() net.Addr WriteMsg(ProtoTypeID, []byte) bool RpcCall(ProtoTypeID, []byte) bool MultipleMsg() ITranMsgMultiple GetUserType() interface{} SetUserType(interface{}) Run() error }
type Option ¶
type Option = func(...interface{})
func ListenAddr ¶
func Module ¶
func Module(m EventReceiver) Option
func ServeHandler ¶
func ServeHandler(serve_handler SessionHandler) Option
func TransportKeepAlive ¶
func TransportMaxCount ¶
func TransportMaxLength ¶
type OptionMgr ¶
type OptionMgr interface {
GetOption() *TransportOption
}
type PingEventMsg ¶
func (*PingEventMsg) GetSender ¶
func (this *PingEventMsg) GetSender() Agent
func (*PingEventMsg) GetType ¶
func (this *PingEventMsg) GetType() event.EventType
func (*PingEventMsg) Reset ¶
func (this *PingEventMsg) Reset()
type PingMgr ¶
type PingMgr struct {
// contains filtered or unexported fields
}
func (*PingMgr) RemovePing ¶
type ProtoTypeID ¶
type ProtoTypeID = uint32
type ServerType ¶
type ServerType uint32
type SessionHandler ¶
type SessionHandler interface { ServeHandler(Agent, ProtoTypeID, []byte) ServeRpc(Agent, ProtoTypeID, []byte) }
type SessionMgr ¶
type TcpClientMgr ¶
type TcpClientMgr struct {
// contains filtered or unexported fields
}
func (*TcpClientMgr) Close ¶
func (this *TcpClientMgr) Close()
func (*TcpClientMgr) Connect ¶
func (this *TcpClientMgr) Connect(addr string, user_type interface{})
func (*TcpClientMgr) GetID ¶
func (this *TcpClientMgr) GetID() ComponentID
func (*TcpClientMgr) GetOption ¶
func (this *TcpClientMgr) GetOption() *TransportOption
func (*TcpClientMgr) GetType ¶
func (this *TcpClientMgr) GetType() ComponentType
func (*TcpClientMgr) Start ¶
func (this *TcpClientMgr) Start() bool
type TcpConn ¶
type TcpConn struct {
// contains filtered or unexported fields
}
func (*TcpConn) GetOption ¶
func (n *TcpConn) GetOption() *TransportOption
func (*TcpConn) GetUserType ¶
func (n *TcpConn) GetUserType() interface{}
func (*TcpConn) MultipleMsg ¶
func (n *TcpConn) MultipleMsg() ITranMsgMultiple
func (*TcpConn) RemoteAddr ¶
func (*TcpConn) SetUserType ¶
func (n *TcpConn) SetUserType(t interface{})
type TcpServerMgr ¶
type TcpServerMgr struct {
// contains filtered or unexported fields
}
func (*TcpServerMgr) Address ¶
func (this *TcpServerMgr) Address() net.Addr
func (*TcpServerMgr) Close ¶
func (this *TcpServerMgr) Close()
func (*TcpServerMgr) GetID ¶
func (this *TcpServerMgr) GetID() ComponentID
func (*TcpServerMgr) GetOption ¶
func (this *TcpServerMgr) GetOption() *TransportOption
func (*TcpServerMgr) GetType ¶
func (this *TcpServerMgr) GetType() ComponentType
func (*TcpServerMgr) Start ¶
func (this *TcpServerMgr) Start() bool
type TimerHandler ¶
type TimerHandler = timer.TimerHandler
type TimerManager ¶
type TimerManager = timer.TimerManager
type TransportMsgPack ¶
type TransportMsgPack struct { Buf []byte // contains filtered or unexported fields }
func (*TransportMsgPack) GetType ¶
func (m *TransportMsgPack) GetType() byte
type TransportMultiple ¶
type TransportMultiple struct {
// contains filtered or unexported fields
}
func (*TransportMultiple) Done ¶
func (m *TransportMultiple) Done() bool
func (*TransportMultiple) GetType ¶
func (m *TransportMultiple) GetType() byte
func (*TransportMultiple) RpcCall ¶
func (m *TransportMultiple) RpcCall(msgiD ProtoTypeID, b []byte) bool
func (*TransportMultiple) WriteMsg ¶
func (m *TransportMultiple) WriteMsg(msgID ProtoTypeID, b []byte) bool
type TransportOption ¶
type TransportOption struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.