Documentation ¶
Index ¶
- type Conn
- type ControlType
- type NetConn
- func (nc *NetConn) Close() error
- func (nc *NetConn) LocalAddr() net.Addr
- func (nc *NetConn) ReadMessage(mt ControlType) ([]byte, error)
- func (nc *NetConn) RemoteAddr() net.Addr
- func (nc *NetConn) SetReadDeadline(t time.Time) error
- func (nc *NetConn) SetWriteDeadline(t time.Time) error
- func (nc *NetConn) WriteMessage(mt ControlType, data []byte) error
- type WSConn
- func (wsc *WSConn) Close() error
- func (wsc *WSConn) LocalAddr() net.Addr
- func (wsc *WSConn) ReadMessage(ct ControlType) ([]byte, error)
- func (wsc *WSConn) RemoteAddr() net.Addr
- func (wsc *WSConn) SetReadDeadline(t time.Time) error
- func (wsc *WSConn) SetWriteDeadline(t time.Time) error
- func (wsc *WSConn) WriteMessage(ct ControlType, data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { // WriteMessage writes data to the connection. WriteMessage(mt ControlType, data []byte) error // ReadMessage reads data from the connection. ReadMessage(mt ControlType) ([]byte, error) // Close closes the connection. // Any blocked Read or Write operations will be unblocked and return errors. Close() error // LocalAddr returns the local network address. LocalAddr() net.Addr // RemoteAddr returns the remote network address. RemoteAddr() net.Addr // SetReadDeadline sets the deadline for future Read calls // and any currently-blocked Read call. // A zero value for t means Read will not time out. SetReadDeadline(t time.Time) error // SetWriteDeadline sets the deadline for future Write calls // and any currently-blocked Write call. // Even if write times out, it may return n > 0, indicating that // some of the data was successfully written. // A zero value for t means Write will not time out. SetWriteDeadline(t time.Time) error }
Conn 统一的连接操作
type ControlType ¶
type ControlType int
ControlType 控制类型
const ( // TextMessage 文本消息 TextMessage ControlType = 1 // BinaryMessage 二进制消息 BinaryMessage ControlType = 2 )
func (ControlType) String ¶
func (ct ControlType) String() string
type NetConn ¶
type NetConn struct {
// contains filtered or unexported fields
}
NetConn golang默认连接
func (*NetConn) ReadMessage ¶
func (nc *NetConn) ReadMessage(mt ControlType) ([]byte, error)
func (*NetConn) RemoteAddr ¶
func (*NetConn) WriteMessage ¶
func (nc *NetConn) WriteMessage(mt ControlType, data []byte) error
type WSConn ¶
WSConn gorilla websocket连接
func (*WSConn) ReadMessage ¶
func (wsc *WSConn) ReadMessage(ct ControlType) ([]byte, error)
func (*WSConn) RemoteAddr ¶
func (*WSConn) WriteMessage ¶
func (wsc *WSConn) WriteMessage(ct ControlType, data []byte) error
Click to show internal directories.
Click to hide internal directories.