Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { // Write message to the connection. Write(data []byte) error // Read message from the connection. Read() ([]byte, error) // Close the connection. Close() error // GetConnInfo return the connection info GetConnInfo() *ConnectionInfo }
Connection expression a network keep-alive connection, WebSocket, tcp etc
type ConnectionHandler ¶
type ConnectionHandler func(conn Connection)
type ConnectionInfo ¶
type ConnectionProxy ¶
type ConnectionProxy struct {
// contains filtered or unexported fields
}
ConnectionProxy expression a binder of Connection.
func (ConnectionProxy) Close ¶
func (c ConnectionProxy) Close() error
func (ConnectionProxy) GetConnInfo ¶
func (c ConnectionProxy) GetConnInfo() *ConnectionInfo
func (ConnectionProxy) Read ¶
func (c ConnectionProxy) Read() ([]byte, error)
func (ConnectionProxy) Write ¶
func (c ConnectionProxy) Write(data []byte) error
type Server ¶
type Server interface { SetConnHandler(handler ConnectionHandler) Run(host string, port int) error }
func NewWsServer ¶
func NewWsServer(options *WsServerOptions) Server
NewWsServer options can be nil, use default value when nil.
type TcpConnection ¶
type TcpConnection struct {
// contains filtered or unexported fields
}
func NewTcpConn ¶
func NewTcpConn(c *net.TCPConn) *TcpConnection
func (TcpConnection) Close ¶
func (t TcpConnection) Close() error
func (TcpConnection) GetConnInfo ¶
func (t TcpConnection) GetConnInfo() *ConnectionInfo
func (TcpConnection) Read ¶
func (t TcpConnection) Read() ([]byte, error)
func (TcpConnection) Write ¶
func (t TcpConnection) Write(data []byte) error
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func NewTcpServer() *TcpServer
func (*TcpServer) SetConnHandler ¶
func (t *TcpServer) SetConnHandler(handler ConnectionHandler)
type WsConnection ¶
type WsConnection struct {
// contains filtered or unexported fields
}
func NewWsConnection ¶
func NewWsConnection(conn *websocket.Conn, options *WsServerOptions) *WsConnection
func (*WsConnection) Close ¶
func (c *WsConnection) Close() error
func (*WsConnection) GetConnInfo ¶
func (c *WsConnection) GetConnInfo() *ConnectionInfo
func (*WsConnection) Read ¶
func (c *WsConnection) Read() ([]byte, error)
func (*WsConnection) Write ¶
func (c *WsConnection) Write(data []byte) error
type WsServer ¶
type WsServer struct {
// contains filtered or unexported fields
}
func (*WsServer) SetConnHandler ¶
func (ws *WsServer) SetConnHandler(handler ConnectionHandler)
Click to show internal directories.
Click to hide internal directories.