Documentation
¶
Index ¶
- type CallBack
- type ConnBucket
- type Packet
- type Protocol
- type 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
- 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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallBack ¶
type CallBack interface {
OnConnected(conn *TCPConnection)
OnMessage(conn *TCPConnection, p Packet)
OnDisconnected(conn *TCPConnection)
OnError(err error)
}
type ConnBucket ¶
type ConnBucket struct {
// contains filtered or unexported fields
}
func NewConnBucket ¶
func NewConnBucket() *ConnBucket
func (*ConnBucket) Delete ¶
func (b *ConnBucket) Delete(id string)
func (*ConnBucket) Get ¶
func (b *ConnBucket) Get(id string) *TCPConnection
func (*ConnBucket) GetAll ¶
func (b *ConnBucket) GetAll() map[string]*TCPConnection
func (*ConnBucket) Put ¶
func (b *ConnBucket) Put(id string, c *TCPConnection)
type TCPConnection ¶
type TCPConnection struct {
// contains filtered or unexported fields
}
func NewTCPConnection ¶
func NewTCPConnection(conn *net.TCPConn, callback CallBack, protocol Protocol) *TCPConnection
func (*TCPConnection) Close ¶
func (c *TCPConnection) Close(flag int)
func (*TCPConnection) GetLocalAddr ¶
func (c *TCPConnection) GetLocalAddr() net.Addr
func (*TCPConnection) GetLocalIPAddress ¶
func (c *TCPConnection) GetLocalIPAddress() string
func (*TCPConnection) GetRawConn ¶
func (c *TCPConnection) GetRawConn() *net.TCPConn
func (*TCPConnection) GetRemoteAddr ¶
func (c *TCPConnection) GetRemoteAddr() net.Addr
func (*TCPConnection) GetRemoteIPAddress ¶
func (c *TCPConnection) GetRemoteIPAddress() string
func (*TCPConnection) IsClosed ¶
func (c *TCPConnection) IsClosed() bool
func (*TCPConnection) ReadPacket ¶
func (c *TCPConnection) ReadPacket() (Packet, error)
func (*TCPConnection) Serve ¶
func (c *TCPConnection) Serve() error
func (*TCPConnection) WritePacket ¶
func (c *TCPConnection) WritePacket(p Packet) error
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
func (*TCPServer) GetAllTCPConn ¶
func (srv *TCPServer) GetAllTCPConn() []*TCPConnection
func (*TCPServer) GetTCPConn ¶
func (srv *TCPServer) GetTCPConn(key string) *TCPConnection
func (*TCPServer) ListenAndServe ¶
func (*TCPServer) SetReadTimeOut ¶
func (*TCPServer) SetWriteTimeOut ¶
Click to show internal directories.
Click to hide internal directories.