Versions in this module Expand all Collapse all v0 v0.1.0 Jun 12, 2018 Changes in this version + type CallBack interface + OnConnected func(conn *TCPConnection) + OnDisconnected func(conn *TCPConnection) + OnError func(err error) + OnMessage func(conn *TCPConnection, p Packet) + type ConnBucket struct + func NewConnBucket() *ConnBucket + func (b *ConnBucket) Delete(id string) + func (b *ConnBucket) Get(id string) *TCPConnection + func (b *ConnBucket) GetAll() map[string]*TCPConnection + func (b *ConnBucket) Put(id string, c *TCPConnection) + type Packet interface + Bytes func() []byte + type Protocol interface + ReadPacket func(reader io.Reader) (Packet, error) + WritePacket func(writer io.Writer, msg Packet) error + type TCPConnection struct + func NewTCPConnection(conn *net.TCPConn, callback CallBack, protocol Protocol) *TCPConnection + func (c *TCPConnection) Close(flag int) + func (c *TCPConnection) GetLocalAddr() net.Addr + func (c *TCPConnection) GetLocalIPAddress() string + func (c *TCPConnection) GetRawConn() *net.TCPConn + func (c *TCPConnection) GetRemoteAddr() net.Addr + func (c *TCPConnection) GetRemoteIPAddress() string + func (c *TCPConnection) IsClosed() bool + func (c *TCPConnection) ReadPacket() (Packet, error) + func (c *TCPConnection) Serve() error + func (c *TCPConnection) WritePacket(p Packet) error + type TCPServer struct + func NewTCPServer(addr string, callback CallBack, protocol Protocol) *TCPServer + func (srv *TCPServer) Close() + func (srv *TCPServer) Connect(ip string, callback CallBack, protocol Protocol) (*TCPConnection, error) + func (srv *TCPServer) GetAllTCPConn() []*TCPConnection + func (srv *TCPServer) GetTCPConn(key string) *TCPConnection + func (srv *TCPServer) ListenAndServe() error + func (srv *TCPServer) Serve(l *net.TCPListener) error + func (srv *TCPServer) SetReadTimeOut(t time.Duration) + func (srv *TCPServer) SetWriteTimeOut(t time.Duration)