Documentation ¶
Index ¶
- Variables
- func Accept(listener net.Listener) (net.Conn, error)
- func AcceptTCP(listener *net.TCPListener) (*net.TCPConn, error)
- func ListenUdp(addr2 string) (net.PacketConn, error)
- func RegisterProtocol(name string, protocol Protocol)
- type BufferedConn
- func (b *BufferedConn) BufioReader() *bufio.Reader
- func (b *BufferedConn) Discard(n int) (int, error)
- func (b *BufferedConn) Peek(n int) ([]byte, error)
- func (b *BufferedConn) PeekByte() (uint8, error)
- func (b *BufferedConn) PeekUint32() (uint32, error)
- func (b *BufferedConn) Read(p []byte) (int, error)
- func (b *BufferedConn) String() string
- type ClearSendChan
- type ClientConfig
- type Codec
- type Connection
- type ConnectionFactory
- type ConnectionManager
- type MessageBase
- type PeekAble
- type Protocol
- type ProtocolFunc
- type ServerConfig
- type TcpClient
- func (c *TcpClient) AutoReconnect() bool
- func (c *TcpClient) GetConnection() *TcpConnection
- func (c *TcpClient) GetRemoteAddress() string
- func (c *TcpClient) GetRemoteName() string
- func (c *TcpClient) GetTimer() time.Duration
- func (c *TcpClient) OnConnectionClosed(conn Connection)
- func (c *TcpClient) Reconnect()
- func (c *TcpClient) Send(msg interface{}) error
- func (c *TcpClient) Serve() bool
- func (c *TcpClient) SetTimer(d time.Duration)
- func (c *TcpClient) StartTimer()
- func (c *TcpClient) Stop()
- type TcpClientCallBack
- type TcpClientGroupManager
- func (cgm *TcpClientGroupManager) AddClient(name string, address string)
- func (cgm *TcpClientGroupManager) BroadcastData(name string, msg interface{}) error
- func (cgm *TcpClientGroupManager) GetConfig() interface{}
- func (cgm *TcpClientGroupManager) RemoveClient(name string, address string)
- func (cgm *TcpClientGroupManager) SendData(name string, msg interface{}) error
- func (cgm *TcpClientGroupManager) SendDataToAddress(name, address string, msg interface{}) error
- func (cgm *TcpClientGroupManager) Serve() bool
- func (cgm *TcpClientGroupManager) Stop() bool
- type TcpConnection
- func (c *TcpConnection) Close() error
- func (c *TcpConnection) Codec() Codec
- func (c *TcpConnection) GetConnID() uint64
- func (c *TcpConnection) GetNetConn() net.Conn
- func (c *TcpConnection) IsClosed() bool
- func (c *TcpConnection) IsWebsocket() bool
- func (c *TcpConnection) LoadAddr() net.Addr
- func (c *TcpConnection) Name() string
- func (c *TcpConnection) Receive() (interface{}, error)
- func (c *TcpConnection) RemoteAddr() net.Addr
- func (c *TcpConnection) Send(msg interface{}) error
- func (c *TcpConnection) String() string
- type TcpConnectionCallback
- type TcpServer
- func (s *TcpServer) GetConnection(connID uint64) *TcpConnection
- func (s *TcpServer) OnConnectionClosed(conn Connection)
- func (s *TcpServer) Pause()
- func (s *TcpServer) SendByConnID(connID uint64, msg interface{}) error
- func (s *TcpServer) Serve()
- func (s *TcpServer) Serve2()
- func (s *TcpServer) Stop()
- type TcpServer2
- type TcpServerArgs
- type TcpServerConfig
- type UdpConnection
- type UdpConnectionCallback
- type UdpServer
- type UdpServerArgs
- type WebsocketConfig
- type WebsocketServer
- func (s *WebsocketServer) GetConnection(connID uint64) *TcpConnection
- func (s *WebsocketServer) OnConnectionClosed(conn Connection)
- func (s *WebsocketServer) Pause()
- func (s *WebsocketServer) SendByConnID(connID uint64, msg interface{}) error
- func (s *WebsocketServer) Serve()
- func (s *WebsocketServer) Stop()
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ConnectionClosedError = errors.New("connection Closed") ConnectionBlockedError = errors.New("connection Blocked") )
Functions ¶
func RegisterProtocol ¶
Types ¶
type BufferedConn ¶
type BufferedConn struct { net.Conn // So that most methods are embedded // contains filtered or unexported fields }
func NewBufferedConn ¶
func NewBufferedConn(c net.Conn) *BufferedConn
func NewBufferedConnSize ¶
func NewBufferedConnSize(c net.Conn, n int) *BufferedConn
func (*BufferedConn) BufioReader ¶
func (b *BufferedConn) BufioReader() *bufio.Reader
func (*BufferedConn) PeekByte ¶
func (b *BufferedConn) PeekByte() (uint8, error)
func (*BufferedConn) PeekUint32 ¶
func (b *BufferedConn) PeekUint32() (uint32, error)
func (*BufferedConn) String ¶
func (b *BufferedConn) String() string
type ClearSendChan ¶
type ClearSendChan interface {
ClearSendChan(<-chan interface{})
}
type ClientConfig ¶
type Codec ¶
type Codec interface { Receive() (interface{}, error) Send(interface{}) error Close() error Context() interface{} }
func NewCodecByName ¶
func NewCodecByName(name string, rw io.ReadWriter) (Codec, error)
type Connection ¶
type ConnectionFactory ¶
type ConnectionFactory interface {
NewConnection(serverName string) TcpConnection
}
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager() *ConnectionManager
func (*ConnectionManager) Dispose ¶
func (manager *ConnectionManager) Dispose()
func (*ConnectionManager) GetConnection ¶
func (manager *ConnectionManager) GetConnection(connID uint64) Connection
type MessageBase ¶
type ProtocolFunc ¶
type ProtocolFunc func(rw io.ReadWriter) (Codec, error)
func (ProtocolFunc) NewCodec ¶
func (pf ProtocolFunc) NewCodec(rw io.ReadWriter) (Codec, error)
type ServerConfig ¶
type TcpClient ¶
type TcpClient struct {
// contains filtered or unexported fields
}
func NewTcpClient ¶
func NewTcpClient(name string, chanSize int, protoName, address string, cb TcpClientCallBack) *TcpClient
func (*TcpClient) AutoReconnect ¶
func (*TcpClient) GetConnection ¶
func (c *TcpClient) GetConnection() *TcpConnection
func (*TcpClient) GetRemoteAddress ¶
func (*TcpClient) GetRemoteName ¶
func (*TcpClient) OnConnectionClosed ¶
func (c *TcpClient) OnConnectionClosed(conn Connection)
func (*TcpClient) StartTimer ¶
func (c *TcpClient) StartTimer()
type TcpClientCallBack ¶
type TcpClientGroupManager ¶
type TcpClientGroupManager struct {
// contains filtered or unexported fields
}
func NewTcpClientGroupManager ¶
func NewTcpClientGroupManager(protoName string, clients map[string][]string, cb TcpClientCallBack) *TcpClientGroupManager
func (*TcpClientGroupManager) AddClient ¶
func (cgm *TcpClientGroupManager) AddClient(name string, address string)
func (*TcpClientGroupManager) BroadcastData ¶
func (cgm *TcpClientGroupManager) BroadcastData(name string, msg interface{}) error
func (*TcpClientGroupManager) GetConfig ¶
func (cgm *TcpClientGroupManager) GetConfig() interface{}
func (*TcpClientGroupManager) RemoveClient ¶
func (cgm *TcpClientGroupManager) RemoveClient(name string, address string)
func (*TcpClientGroupManager) SendData ¶
func (cgm *TcpClientGroupManager) SendData(name string, msg interface{}) error
func (*TcpClientGroupManager) SendDataToAddress ¶
func (cgm *TcpClientGroupManager) SendDataToAddress(name, address string, msg interface{}) error
func (*TcpClientGroupManager) Serve ¶
func (cgm *TcpClientGroupManager) Serve() bool
func (*TcpClientGroupManager) Stop ¶
func (cgm *TcpClientGroupManager) Stop() bool
type TcpConnection ¶
type TcpConnection struct { Context interface{} // contains filtered or unexported fields }
func NewTcpConnection ¶
func NewTcpConnection2 ¶
func (*TcpConnection) Close ¶
func (c *TcpConnection) Close() error
func (*TcpConnection) Codec ¶
func (c *TcpConnection) Codec() Codec
func (*TcpConnection) GetConnID ¶
func (c *TcpConnection) GetConnID() uint64
func (*TcpConnection) GetNetConn ¶
func (c *TcpConnection) GetNetConn() net.Conn
func (*TcpConnection) IsClosed ¶
func (c *TcpConnection) IsClosed() bool
func (*TcpConnection) IsWebsocket ¶
func (c *TcpConnection) IsWebsocket() bool
func (*TcpConnection) LoadAddr ¶
func (c *TcpConnection) LoadAddr() net.Addr
func (*TcpConnection) Name ¶
func (c *TcpConnection) Name() string
func (*TcpConnection) Receive ¶
func (c *TcpConnection) Receive() (interface{}, error)
func (*TcpConnection) RemoteAddr ¶
func (c *TcpConnection) RemoteAddr() net.Addr
func (*TcpConnection) Send ¶
func (c *TcpConnection) Send(msg interface{}) error
func (*TcpConnection) String ¶
func (c *TcpConnection) String() string
type TcpConnectionCallback ¶
type TcpConnectionCallback interface { OnNewConnection(conn *TcpConnection) OnConnectionDataArrived(c *TcpConnection, msg interface{}) error OnConnectionClosed(c *TcpConnection) }
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func NewTcpServer(args TcpServerArgs) *TcpServer
func (*TcpServer) GetConnection ¶
func (s *TcpServer) GetConnection(connID uint64) *TcpConnection
func (*TcpServer) OnConnectionClosed ¶
func (s *TcpServer) OnConnectionClosed(conn Connection)
func (*TcpServer) SendByConnID ¶
type TcpServer2 ¶
type TcpServer2 struct {
// contains filtered or unexported fields
}
func NewTcpServer2 ¶
func NewTcpServer2(c *TcpServerConfig, accepts int, cb TcpConnectionCallback) (s *TcpServer2, err error)
func (*TcpServer2) GetConnection ¶
func (s *TcpServer2) GetConnection(connID uint64) *TcpConnection
func (*TcpServer2) OnConnectionClosed ¶
func (s *TcpServer2) OnConnectionClosed(conn Connection)
func (*TcpServer2) Pause ¶
func (s *TcpServer2) Pause()
func (*TcpServer2) SendByConnID ¶
func (s *TcpServer2) SendByConnID(connID uint64, msg interface{}) error
func (*TcpServer2) Serve ¶
func (s *TcpServer2) Serve()
func (*TcpServer2) Stop ¶
func (s *TcpServer2) Stop()
type TcpServerArgs ¶
type TcpServerConfig ¶
type UdpConnection ¶
type UdpConnection struct {
// contains filtered or unexported fields
}
func NewUdpConnection ¶
func NewUdpConnection() *UdpConnection
type UdpConnectionCallback ¶
type UdpConnectionCallback interface { OnUdpNew(conn *UdpConnection) OnUdpDataArrived(c *UdpConnection, msg interface{}) error OnUdpClosed(c *UdpConnection) }
type UdpServer ¶
type UdpServer struct {
// contains filtered or unexported fields
}
func NewUdpServer ¶
func NewUdpServer(args UdpServerArgs) *UdpServer
type UdpServerArgs ¶
type WebsocketConfig ¶
type WebsocketServer ¶
type WebsocketServer struct {
// contains filtered or unexported fields
}
func NewWebsocketServer ¶
func NewWebsocketServer(c *WebsocketConfig, accepts int, cb TcpConnectionCallback) (s *WebsocketServer, err error)
func (*WebsocketServer) GetConnection ¶
func (s *WebsocketServer) GetConnection(connID uint64) *TcpConnection
func (*WebsocketServer) OnConnectionClosed ¶
func (s *WebsocketServer) OnConnectionClosed(conn Connection)
func (*WebsocketServer) Pause ¶
func (s *WebsocketServer) Pause()
func (*WebsocketServer) SendByConnID ¶
func (s *WebsocketServer) SendByConnID(connID uint64, msg interface{}) error
func (*WebsocketServer) Serve ¶
func (s *WebsocketServer) Serve()
func (*WebsocketServer) Stop ¶
func (s *WebsocketServer) Stop()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.