Documentation
¶
Index ¶
- Variables
- func Dialer(dialer *gorilla.Dialer, requestHeader http.Header) neffos.Dialer
- func Upgrader(upgrader gorilla.Upgrader) neffos.Upgrader
- type Options
- type Socket
- func (s *Socket) Close(code int, reason string, timeout time.Duration) error
- func (s *Socket) NetConn() net.Conn
- func (s *Socket) Ping(timeout time.Duration) error
- func (s *Socket) ReadData(timeout time.Duration) ([]byte, neffos.MessageType, error)
- func (s *Socket) Request() *http.Request
- func (s *Socket) SetReadLimit(n int64)
- func (s *Socket) WriteBinary(body []byte, timeout time.Duration) error
- func (s *Socket) WriteText(body []byte, timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var DefaultDialer = Dialer(gorilla.DefaultDialer, make(http.Header))
DefaultDialer is a gorilla/websocket dialer with all fields set to the default values.
var DefaultUpgrader = Upgrader(gorilla.Upgrader{})
DefaultUpgrader is a gorilla/websocket Upgrader with all fields set to the default values.
Functions ¶
Types ¶
type Socket ¶
Socket completes the `neffos.Socket` interface, it describes the underline websocket connection.
It also implements neffos.SocketCloser, neffos.SocketPinger and neffos.SocketReadLimiter.
func (*Socket) Close ¶ added in v0.0.25
Close sends a close frame with code and reason, waiting at most timeout for the write (one second when timeout is zero), and then closes the connection. A failed close frame write does not stop the close. It is safe to call while other goroutines read and write.
func (*Socket) Ping ¶ added in v0.0.25
Ping sends a ping frame. With a timeout above zero it then waits up to that long for a pong and returns os.ErrDeadlineExceeded when none arrives. With a zero timeout it returns right after the write. Pongs are only seen while another goroutine is inside ReadData.
func (*Socket) ReadData ¶
ReadData reads binary or text messages from the remote connection.
A close frame from the remote side is returned as a neffos.CloseError with its code and reason. A message over the read limit returns an error that matches neffos.ErrMessageTooBig, after a close frame with neffos.CloseMessageTooBig was sent and the rest of the input was dropped for up to a second. A pong from the remote side moves the read deadline forward by timeout.
func (*Socket) SetReadLimit ¶ added in v0.0.25
SetReadLimit sets the largest message, in bytes, ReadData accepts. A bigger message closes the connection with neffos.CloseMessageTooBig. n <= 0 removes the limit.
func (*Socket) WriteBinary ¶
WriteBinary sends a binary message to the remote connection.