Documentation ¶
Index ¶
- Variables
- func Accept(listener net.Listener) (net.Conn, error)
- func AcceptTCP(listener *net.TCPListener) (*net.TCPConn, error)
- func AcceptTCP3(listener *net.TCPListener) (*net.TCPConn, 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 TcpServer3
- type TcpServer3Config
- type TcpServerArgs
- type TcpServerConfig
- type UdpConnection
- func (c *UdpConnection) Close() error
- func (c *UdpConnection) Codec() Codec
- func (c *UdpConnection) GetConnID() uint64
- func (c *UdpConnection) GetNetConn() *net.UDPConn
- func (c *UdpConnection) IsClosed() bool
- func (c *UdpConnection) LoadAddr() net.Addr
- func (c *UdpConnection) Name() string
- func (c *UdpConnection) Receive() (interface{}, error)
- func (c *UdpConnection) RemoteAddr() net.Addr
- func (c *UdpConnection) Send(msg interface{}) error
- func (c *UdpConnection) String() string
- type UdpConnectionCallback
- type UdpServer
- func (s *UdpServer) GetConnection(connID uint64) *UdpConnection
- func (s *UdpServer) OnConnectionClosed(conn Connection)
- func (s *UdpServer) Pause()
- func (s *UdpServer) SendByConnID(connID uint64, msg interface{}) error
- func (s *UdpServer) Serve()
- func (s *UdpServer) Serve2()
- func (s *UdpServer) Stop()
- 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") )
View Source
var ConnectionUdpBlockedError = errors.New("Connection Blocked")
View Source
var ConnectionUdpClosedError = errors.New("Connection Closed")
Functions ¶
func AcceptTCP3 ¶
func AcceptTCP3(listener *net.TCPListener) (*net.TCPConn, error)
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 TcpServer3 ¶
type TcpServer3 struct {
// contains filtered or unexported fields
}
func NewTcpServer3 ¶
func NewTcpServer3(c *TcpServer3Config, accepts int, cb TcpConnectionCallback) (s *TcpServer3, err error)
func (*TcpServer3) GetConnection ¶
func (s *TcpServer3) GetConnection(connID uint64) *TcpConnection
func (*TcpServer3) OnConnectionClosed ¶
func (s *TcpServer3) OnConnectionClosed(conn Connection)
func (*TcpServer3) Pause ¶
func (s *TcpServer3) Pause()
func (*TcpServer3) SendByConnID ¶
func (s *TcpServer3) SendByConnID(connID uint64, msg interface{}) error
func (*TcpServer3) Serve ¶
func (s *TcpServer3) Serve()
func (*TcpServer3) Stop ¶
func (s *TcpServer3) Stop()
type TcpServer3Config ¶
type TcpServerArgs ¶
type TcpServerConfig ¶
type UdpConnection ¶
type UdpConnection struct { Context interface{} // contains filtered or unexported fields }
func NewUdpConnection ¶
func (*UdpConnection) Close ¶
func (c *UdpConnection) Close() error
func (*UdpConnection) Codec ¶
func (c *UdpConnection) Codec() Codec
func (*UdpConnection) GetConnID ¶
func (c *UdpConnection) GetConnID() uint64
func (*UdpConnection) GetNetConn ¶
func (c *UdpConnection) GetNetConn() *net.UDPConn
func (*UdpConnection) IsClosed ¶
func (c *UdpConnection) IsClosed() bool
func (*UdpConnection) LoadAddr ¶
func (c *UdpConnection) LoadAddr() net.Addr
func (*UdpConnection) Name ¶
func (c *UdpConnection) Name() string
func (*UdpConnection) Receive ¶
func (c *UdpConnection) Receive() (interface{}, error)
func (*UdpConnection) RemoteAddr ¶
func (c *UdpConnection) RemoteAddr() net.Addr
func (*UdpConnection) Send ¶
func (c *UdpConnection) Send(msg interface{}) error
func (*UdpConnection) String ¶
func (c *UdpConnection) String() string
type UdpConnectionCallback ¶
type UdpConnectionCallback interface { OnNewConnection(conn *UdpConnection) OnConnectionDataArrived(c *UdpConnection, msg interface{}) error OnConnectionClosed(c *UdpConnection) }
type UdpServer ¶
type UdpServer struct {
// contains filtered or unexported fields
}
func NewUdpServer ¶
func NewUdpServer(args UdpServerArgs) *UdpServer
func (*UdpServer) GetConnection ¶
func (s *UdpServer) GetConnection(connID uint64) *UdpConnection
func (*UdpServer) OnConnectionClosed ¶
func (s *UdpServer) OnConnectionClosed(conn Connection)
func (*UdpServer) SendByConnID ¶
根据ConnId发送数据
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 ¶
Directories ¶
Path | Synopsis |
---|---|
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O.
|
Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer object, creating another object (Reader or Writer) that also implements the interface but provides buffering and some help for textual I/O. |
examples
|
|
Click to show internal directories.
Click to hide internal directories.