Versions in this module Expand all Collapse all v0 v0.1.12 Sep 26, 2022 Changes in this version + var ConnectionBlockedError = errors.New("connection Blocked") + var ConnectionClosedError = errors.New("connection Closed") + 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 struct + func NewBufferedConn(c net.Conn) *BufferedConn + func NewBufferedConnSize(c net.Conn, n int) *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 interface + ClearSendChan func(<-chan interface{}) + type ClientConfig struct + AddrList []string + Balancer string + EtcdAddrs []string + Name string + ProtoName string + type Codec interface + Close func() error + Context func() interface{} + Receive func() (interface{}, error) + Send func(interface{}) error + func NewCodecByName(name string, rw io.ReadWriter) (Codec, error) + type Connection interface + Close func() error + Codec func() Codec + GetConnID func() uint64 + IsClosed func() bool + Receive func() (interface{}, error) + Send func(msg interface{}) error + type ConnectionFactory interface + NewConnection func(serverName string) TcpConnection + type ConnectionManager struct + func NewConnectionManager() *ConnectionManager + func (manager *ConnectionManager) Dispose() + func (manager *ConnectionManager) GetConnection(connID uint64) Connection + type MessageBase interface + Decode func(b []byte) error + Encode func() []byte + type PeekAble interface + Discard func(n int) (int, error) + Peek func(n int) ([]byte, error) + PeekByte func() (uint8, error) + PeekUint32 func() (uint32, error) + type Protocol interface + NewCodec func(rw io.ReadWriter) (Codec, error) + type ProtocolFunc func(rw io.ReadWriter) (Codec, error) + func (pf ProtocolFunc) NewCodec(rw io.ReadWriter) (Codec, error) + type ServerConfig struct + Addr string + Name string + ProtoName string + type TcpClient struct + func NewTcpClient(name string, chanSize int, protoName, address string, cb TcpClientCallBack) *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 interface + OnClientClosed func(c *TcpClient) + OnClientDataArrived func(c *TcpClient, msg interface{}) error + OnClientTimer func(c *TcpClient) + OnNewClient func(c *TcpClient) + type TcpClientGroupManager struct + func NewTcpClientGroupManager(protoName string, clients map[string][]string, cb TcpClientCallBack) *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 struct + Context interface{} + func NewTcpConnection(name string, conn net.Conn, sendChanSize int, codec Codec, cb closeCallback) *TcpConnection + func NewTcpConnection2(name string, conn net.Conn, sendChanSize int, codec Codec, isWebsocket bool, ...) *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 interface + OnConnectionClosed func(c *TcpConnection) + OnConnectionDataArrived func(c *TcpConnection, msg interface{}) error + OnNewConnection func(conn *TcpConnection) + type TcpServer struct + func NewTcpServer(args TcpServerArgs) *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 struct + func NewTcpServer2(c *TcpServerConfig, accepts int, cb TcpConnectionCallback) (s *TcpServer2, err error) + func (s *TcpServer2) GetConnection(connID uint64) *TcpConnection + func (s *TcpServer2) OnConnectionClosed(conn Connection) + func (s *TcpServer2) Pause() + func (s *TcpServer2) SendByConnID(connID uint64, msg interface{}) error + func (s *TcpServer2) Serve() + func (s *TcpServer2) Stop() + type TcpServerArgs struct + ConnectionCallback TcpConnectionCallback + Listener net.Listener + MaxConcurrentConnection int + ProtoName string + SendChanSize int + ServerName string + type TcpServerConfig struct + Addrs []string + Keepalive bool + ProtoName string + ReceiveBuf int + SendBuf int + SendChanSize int + ServerName string + type UdpConnection struct + func NewUdpConnection() *UdpConnection + type UdpConnectionCallback interface + OnUdpClosed func(c *UdpConnection) + OnUdpDataArrived func(c *UdpConnection, msg interface{}) error + OnUdpNew func(conn *UdpConnection) + type UdpServer struct + func NewUdpServer(args UdpServerArgs) *UdpServer + func (s *UdpServer) Pause() + func (s *UdpServer) Serve() + func (s *UdpServer) Stop() + type UdpServerArgs struct + PacketConn *net.UDPConn + ProtoName string + SendChanSize int + ServerName string + type WebsocketConfig struct + Addrs []string + Keepalive bool + ProtoName string + ReceiveBuf int + SendBuf int + SendChanSize int + ServerName string + type WebsocketServer struct + func NewWebsocketServer(c *WebsocketConfig, accepts int, cb TcpConnectionCallback) (s *WebsocketServer, err error) + 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()