gobwas

package
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 15 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDialer = Dialer(gobwas.DefaultDialer)

DefaultDialer is a gobwas/ws dialer with all fields set to the default values.

View Source
var DefaultUpgrader = Upgrader(gobwas.HTTPUpgrader{})

DefaultUpgrader is a gobwas/ws HTTP Upgrader with all fields set to the default values.

Functions

func Dialer

func Dialer(dialer gobwas.Dialer) neffos.Dialer

Dialer is a `neffos.Dialer` type for the gobwas/ws subprotocol implementation. Should be used on `Dial` to create a new client/client-side connection. To send headers to the server set the dialer's `Header` field to a `gobwas.HandshakeHeaderHTTP`.

func Upgrader

func Upgrader(upgrader gobwas.HTTPUpgrader) neffos.Upgrader

Upgrader is a `neffos.Upgrader` type for the gobwas/ws subprotocol implementation. Should be used on `neffos.New` to construct the neffos server.

Types

type Header = gobwas.HandshakeHeaderHTTP

Header is an alias to the adapter that allows the use of `http.Header` as `gobwas/ws.Dialer.HandshakeHeader`.

type Options

type Options = gobwas.Dialer

Options is just an alias for the `gobwas/ws.Dialer` struct type.

type Socket

type Socket struct {
	UnderlyingConn net.Conn
	// contains filtered or unexported fields
}

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

func (s *Socket) Close(code int, reason string, timeout time.Duration) error

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) NetConn

func (s *Socket) NetConn() net.Conn

NetConn returns the underline net connection.

func (*Socket) Ping added in v0.0.25

func (s *Socket) Ping(timeout time.Duration) error

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

func (s *Socket) ReadData(timeout time.Duration) ([]byte, neffos.MessageType, error)

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) Request

func (s *Socket) Request() *http.Request

Request returns the http request value.

func (*Socket) SetReadLimit added in v0.0.25

func (s *Socket) SetReadLimit(n int64)

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

func (s *Socket) WriteBinary(body []byte, timeout time.Duration) error

WriteBinary sends a binary message to the remote connection.

func (*Socket) WriteText

func (s *Socket) WriteText(body []byte, timeout time.Duration) error

WriteText sends a text message to the remote connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址