Documentation
¶
Index ¶
- Variables
- func Dialer(dialer gobwas.Dialer) neffos.Dialer
- func Upgrader(upgrader gobwas.HTTPUpgrader) neffos.Upgrader
- type Header
- 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(gobwas.DefaultDialer)
DefaultDialer is a gobwas/ws dialer with all fields set to the default values.
var DefaultUpgrader = Upgrader(gobwas.HTTPUpgrader{})
DefaultUpgrader is a gobwas/ws HTTP Upgrader with all fields set to the default values.
Functions ¶
Types ¶
type Header ¶
type Header = gobwas.HandshakeHeaderHTTP
Header is an alias to the adapter that allows the use of `http.Header` as `gobwas/ws.Dialer.HandshakeHeader`.
type Socket ¶
Socket completes the `neffos.Socket` interface, it describes the underline websocket connection.
It also implements neffos.SocketCloser, neffos.SocketPinger and neffos.SocketReadLimiter. Every frame it writes, control frames included, goes out under one mutex, so frames never interleave on the wire, and nothing is written after its close frame.
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. The reason should fit in 123 bytes; neffos.Conn trims it before calling 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 answered and returned as a neffos.CloseError with its code and reason. A message over the read limit sends a close frame with neffos.CloseMessageTooBig, drops the rest of the input for up to a second, closes the connection and returns neffos.ErrMessageTooBig. 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. A ReadData call already in progress keeps the limit it started with.
func (*Socket) WriteBinary ¶
WriteBinary sends a binary message to the remote connection.