Documentation ¶
Index ¶
- Constants
- func Dial(addr string, ctx *lokas.Context) (*conn.Conn, error)
- func DialEx(addr string, ctx *lokas.Context, retryWait time.Duration) chan struct{}
- type ClientSession
- func (this *ClientSession) AsyncCall(actorId util.ID, transId uint32, req protocol.ISerializable, ...) error
- func (this *ClientSession) Call(actorId util.ID, transId uint32, req protocol.ISerializable, ...) error
- func (this *ClientSession) CloneEntity() *ecs.Entity
- func (this *ClientSession) GetConn() lokas.IConn
- func (this *ClientSession) GetId() util.ID
- func (this *ClientSession) GetProcess() lokas.IProcess
- func (this *ClientSession) HandleMessage(f func(msg *protocol.BinaryMessage))
- func (this *ClientSession) OnClose(conn lokas.IConn)
- func (this *ClientSession) OnCreate() error
- func (this *ClientSession) OnDestroy() error
- func (this *ClientSession) OnMessage(actorId util.ID, transId uint32, msg protocol.ISerializable) error
- func (this *ClientSession) OnOpen(conn lokas.IConn)
- func (this *ClientSession) OnRecv(conn lokas.IConn, data []byte)
- func (this *ClientSession) PongHandler(pong *protocol.Pong)
- func (this *ClientSession) SendMessage(actorId util.ID, transId uint32, msg protocol.ISerializable) error
- func (this *ClientSession) SetId(id util.ID)
- func (this *ClientSession) SetProcess(process lokas.IProcess)
- func (this *ClientSession) Start() error
- func (this *ClientSession) Stop() error
- func (this *ClientSession) Type() string
- func (this *ClientSession) Update(dt time.Duration, now time.Time)
- func (this *ClientSession) Write(data []byte) error
- type Server
- type SessionOption
- type TcpClient
- func (this *TcpClient) Call(transId uint32, req interface{}) (interface{}, error)
- func (this *TcpClient) ClearContext(err error)
- func (this *TcpClient) Connect(addr string) *promise.Promise
- func (this *TcpClient) Connected() bool
- func (this *TcpClient) Disconnect(b bool) *promise.Promise
- func (this *TcpClient) MessageHandler(msg *protocol.BinaryMessage)
- func (this *TcpClient) Off(cmdId uint16, listener events.Listener)
- func (this *TcpClient) OnClose(conn lokas.IConn)
- func (this *TcpClient) OnMessage(cmdId protocol.BINARY_TAG, listeners ...events.Listener)
- func (this *TcpClient) OnOpen(conn lokas.IConn)
- func (this *TcpClient) OnRecvCmd(cmdId protocol.BINARY_TAG, time time.Duration) *promise.Promise
- func (this *TcpClient) Request(req interface{}, resp interface{}) *promise.Promise
- func (this *TcpClient) SendMessage(transId uint32, msg interface{})
Constants ¶
View Source
const (
PingInterval = time.Second * 3
)
View Source
const (
TimeOut = time.Second * 15
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientSession ¶
type ClientSession struct { util.ID Messages chan []byte Conn lokas.IConn Protocol protocol.TYPE OnCloseFunc func(conn lokas.IConn) OnOpenFunc func(conn lokas.IConn) MsgHandler func(msg *protocol.BinaryMessage) // contains filtered or unexported fields }
func NewClientSession ¶
func NewClientSession(conn lokas.IConn, id util.ID, manager lokas.ISessionManager, opts ...SessionOption) *ClientSession
func (*ClientSession) AsyncCall ¶
func (this *ClientSession) AsyncCall(actorId util.ID, transId uint32, req protocol.ISerializable, resp protocol.ISerializable) error
func (*ClientSession) Call ¶
func (this *ClientSession) Call(actorId util.ID, transId uint32, req protocol.ISerializable, resp protocol.ISerializable) error
func (*ClientSession) CloneEntity ¶
func (this *ClientSession) CloneEntity() *ecs.Entity
func (*ClientSession) GetConn ¶
func (this *ClientSession) GetConn() lokas.IConn
func (*ClientSession) GetId ¶
func (this *ClientSession) GetId() util.ID
func (*ClientSession) GetProcess ¶
func (this *ClientSession) GetProcess() lokas.IProcess
func (*ClientSession) HandleMessage ¶
func (this *ClientSession) HandleMessage(f func(msg *protocol.BinaryMessage))
func (*ClientSession) OnClose ¶
func (this *ClientSession) OnClose(conn lokas.IConn)
func (*ClientSession) OnCreate ¶
func (this *ClientSession) OnCreate() error
func (*ClientSession) OnDestroy ¶
func (this *ClientSession) OnDestroy() error
func (*ClientSession) OnMessage ¶
func (this *ClientSession) OnMessage(actorId util.ID, transId uint32, msg protocol.ISerializable) error
func (*ClientSession) OnOpen ¶
func (this *ClientSession) OnOpen(conn lokas.IConn)
func (*ClientSession) OnRecv ¶
func (this *ClientSession) OnRecv(conn lokas.IConn, data []byte)
func (*ClientSession) PongHandler ¶
func (this *ClientSession) PongHandler(pong *protocol.Pong)
func (*ClientSession) SendMessage ¶
func (this *ClientSession) SendMessage(actorId util.ID, transId uint32, msg protocol.ISerializable) error
func (*ClientSession) SetId ¶
func (this *ClientSession) SetId(id util.ID)
func (*ClientSession) SetProcess ¶
func (this *ClientSession) SetProcess(process lokas.IProcess)
func (*ClientSession) Start ¶
func (this *ClientSession) Start() error
func (*ClientSession) Stop ¶
func (this *ClientSession) Stop() error
func (*ClientSession) Type ¶
func (this *ClientSession) Type() string
func (*ClientSession) Write ¶
func (this *ClientSession) Write(data []byte) error
type Server ¶
type Server struct { Context *lokas.Context // contains filtered or unexported fields }
func (*Server) GetActiveConnNum ¶
GetActiveConnNum get count of active connections
type SessionOption ¶
type SessionOption func(*ClientSession)
func WithCloseFunc ¶
func WithCloseFunc(closeFunc func(conn lokas.IConn)) SessionOption
func WithMsgHandler ¶
func WithMsgHandler(msgHandler func(msg *protocol.BinaryMessage)) SessionOption
func WithOpenFunc ¶
func WithOpenFunc(closeFunc func(conn lokas.IConn)) SessionOption
func WithProtocol ¶
func WithProtocol(protocol protocol.TYPE) SessionOption
type TcpClient ¶
type TcpClient struct { events.EventEmmiter *ClientSession Closing bool Opening bool Protocol protocol.TYPE // contains filtered or unexported fields }
func NewTcpClient ¶
func NewTcpClient(opts ...SessionOption) *TcpClient
func (*TcpClient) ClearContext ¶
func (*TcpClient) MessageHandler ¶
func (this *TcpClient) MessageHandler(msg *protocol.BinaryMessage)
func (*TcpClient) OnMessage ¶
func (this *TcpClient) OnMessage(cmdId protocol.BINARY_TAG, listeners ...events.Listener)
func (*TcpClient) SendMessage ¶
Click to show internal directories.
Click to hide internal directories.