Documentation
¶
Index ¶
- type ConnectionStore
- type IntRange
- type MultiplexConn
- func (mc *MultiplexConn) Close() error
- func (mc *MultiplexConn) HandleNewConn(conn *WsConnAdapter)
- func (mc *MultiplexConn) LocalAddr() net.Addr
- func (mc *MultiplexConn) Read(b []byte) (n int, err error)
- func (mc *MultiplexConn) ReadFrom(b []byte) (n int, addr transport.SockAddr, error error)
- func (mc *MultiplexConn) RemoteAddr() net.Addr
- func (mc *MultiplexConn) SetDeadline(t time.Time) error
- func (mc *MultiplexConn) SetReadDeadline(t time.Time) error
- func (mc *MultiplexConn) SetWriteDeadline(t time.Time) error
- func (mc *MultiplexConn) Write(b []byte) (n int, err error)
- type WsAddr
- type WsConnAdapter
- func (wsc *WsConnAdapter) ActuallyClose() error
- func (wsc *WsConnAdapter) Close() error
- func (wsc *WsConnAdapter) LocalAddr() net.Addr
- func (wsc *WsConnAdapter) Read(b []byte) (n int, err error)
- func (wsc *WsConnAdapter) ReadFrom(b []byte) (n int, addr transport.SockAddr, err error)
- func (wsc *WsConnAdapter) RemoteAddr() net.Addr
- func (wsc *WsConnAdapter) SetDeadline(t time.Time) error
- func (wsc *WsConnAdapter) SetReadDeadline(t time.Time) error
- func (wsc *WsConnAdapter) SetWriteDeadline(t time.Time) error
- func (wsc *WsConnAdapter) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionStore ¶ added in v1.0.8
type ConnectionStore struct {
// contains filtered or unexported fields
}
func NewConnectionStore ¶ added in v1.0.8
func NewConnectionStore() *ConnectionStore
func (*ConnectionStore) ConnCacheGet ¶ added in v1.0.8
func (cs *ConnectionStore) ConnCacheGet(addr net.Addr) (*WsConnAdapter, bool, error)
ConnCacheGet get connection from cache.
func (*ConnectionStore) ConnCacheRemove ¶ added in v1.0.8
func (cs *ConnectionStore) ConnCacheRemove(addr net.Addr) bool
ConnCacheRemove remove connection from cache.
func (*ConnectionStore) ConnCacheSet ¶ added in v1.0.8
func (cs *ConnectionStore) ConnCacheSet(addr net.Addr, conn *WsConnAdapter) error
ConnCacheSet store connection in cache.
type MultiplexConn ¶
type MultiplexConn struct {
// contains filtered or unexported fields
}
func NewMuxConn ¶
func NewMuxConn(laddr transport.SockAddr, logger smudge.Logger) (*MultiplexConn, chan net.Addr)
func (*MultiplexConn) Close ¶
func (mc *MultiplexConn) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*MultiplexConn) HandleNewConn ¶
func (mc *MultiplexConn) HandleNewConn(conn *WsConnAdapter)
func (*MultiplexConn) LocalAddr ¶
func (mc *MultiplexConn) LocalAddr() net.Addr
LocalAddr returns the local network address, if known.
func (*MultiplexConn) Read ¶
func (mc *MultiplexConn) Read(b []byte) (n int, err error)
Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*MultiplexConn) RemoteAddr ¶
func (mc *MultiplexConn) RemoteAddr() net.Addr
RemoteAddr returns the remote network address, if known.
func (*MultiplexConn) SetDeadline ¶
func (mc *MultiplexConn) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*MultiplexConn) SetReadDeadline ¶
func (mc *MultiplexConn) SetReadDeadline(t time.Time) error
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.
func (*MultiplexConn) SetWriteDeadline ¶
func (mc *MultiplexConn) SetWriteDeadline(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.
type WsConnAdapter ¶
WsConnAdapter adapter (wrapper) around web socket connection for correspond net.Conn interface.
func NewWsConnAdapter ¶ added in v1.0.7
NewWsConnAdapter create new websocket conn adapter. If req is nil -> return remote socket addr as is. If requst not nil and contains X-Real-IP, return adapter with replaced remote address.
func (*WsConnAdapter) ActuallyClose ¶
func (wsc *WsConnAdapter) ActuallyClose() error
ActuallyClose actyally close websocket connection.
func (*WsConnAdapter) Close ¶
func (wsc *WsConnAdapter) Close() error
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors. **NOTICE** this function do nothing, because we don't want the connection to be closed after every data transfer.
func (*WsConnAdapter) LocalAddr ¶
func (wsc *WsConnAdapter) LocalAddr() net.Addr
LocalAddr returns the local network address, if known.
func (*WsConnAdapter) Read ¶
func (wsc *WsConnAdapter) Read(b []byte) (n int, err error)
Read reads data from the connection. Read can be made to time out and return an error after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*WsConnAdapter) RemoteAddr ¶
func (wsc *WsConnAdapter) RemoteAddr() net.Addr
RemoteAddr returns the remote network address, if known.
func (*WsConnAdapter) SetDeadline ¶
func (wsc *WsConnAdapter) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*WsConnAdapter) SetReadDeadline ¶
func (wsc *WsConnAdapter) SetReadDeadline(t time.Time) error
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.
func (*WsConnAdapter) SetWriteDeadline ¶
func (wsc *WsConnAdapter) SetWriteDeadline(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.