Documentation ¶
Index ¶
- Variables
- func Accept(listener net.Listener) (net.Conn, error)
- func RegisterProtocol(name string, protocol Protocol)
- type ClearSendChan
- type Codec
- type Connection
- type ConnectionFactory
- type ConnectionManager
- type MessageBase
- type Protocol
- type ProtocolFunc
- 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) StartTimer()
- func (c *TcpClient) Stop()
- type TcpClientCallBack
- type TcpClientGroupManager
- func (this *TcpClientGroupManager) AddClient(name string, address string)
- func (this *TcpClientGroupManager) BroadcastData(name string, msg interface{}) error
- func (this *TcpClientGroupManager) GetConfig() interface{}
- func (this *TcpClientGroupManager) RemoveClient(name string, address string)
- func (this *TcpClientGroupManager) SendData(name string, msg interface{}) error
- func (this *TcpClientGroupManager) SendDataToAddress(name, address string, msg interface{}) error
- func (this *TcpClientGroupManager) Serve() bool
- func (this *TcpClientGroupManager) Stop() bool
- type TcpConnection
- func (c *TcpConnection) Close() error
- func (c *TcpConnection) Codec() Codec
- func (c *TcpConnection) GetConnID() uint64
- func (c *TcpConnection) IsClosed() 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
- type TcpServerArgs
Constants ¶
This section is empty.
Variables ¶
View Source
var ConnectionBlockedError = errors.New("Connection Blocked")
View Source
var ConnectionClosedError = errors.New("Connection Closed")
Functions ¶
func RegisterProtocol ¶
Types ¶
type ClearSendChan ¶
type ClearSendChan interface {
ClearSendChan(<-chan interface{})
}
type Codec ¶
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 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 (this *TcpClientGroupManager) AddClient(name string, address string)
func (*TcpClientGroupManager) BroadcastData ¶
func (this *TcpClientGroupManager) BroadcastData(name string, msg interface{}) error
func (*TcpClientGroupManager) GetConfig ¶
func (this *TcpClientGroupManager) GetConfig() interface{}
func (*TcpClientGroupManager) RemoveClient ¶
func (this *TcpClientGroupManager) RemoveClient(name string, address string)
func (*TcpClientGroupManager) SendData ¶
func (this *TcpClientGroupManager) SendData(name string, msg interface{}) error
func (*TcpClientGroupManager) SendDataToAddress ¶
func (this *TcpClientGroupManager) SendDataToAddress(name, address string, msg interface{}) error
func (*TcpClientGroupManager) Serve ¶
func (this *TcpClientGroupManager) Serve() bool
func (*TcpClientGroupManager) Stop ¶
func (this *TcpClientGroupManager) Stop() bool
type TcpConnection ¶
type TcpConnection struct { Context interface{} // contains filtered or unexported fields }
func NewTcpConnection ¶
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) IsClosed ¶
func (c *TcpConnection) IsClosed() 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 ¶
根据ConnId发送数据
type TcpServerArgs ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.