class

LavinMQ::WebSocketIO

Inherits IO::Buffered < IO < Reference < Object

Exposes a WebSocket as a byte stream to the AMQP and MQTT servers. Frame payloads are read straight into the caller's buffer, so a fragmented message needs no reassembly. Every frame the server sends, data, pong or close, goes through one write lock, like a client's write lock.

Constants

CLOSE_FRAME_TIMEOUT = 1.second

Constructors

new(socket : IO)

socket is the connection the WebSocket runs over

Source

Instance methods

read_timeout=(timeout : Time::Span | Nil)

Pings and pongs don't count as activity, the timeout is for data, like the MQTT keepalive. The socket's own timeout covers a silent connection.

Source
shutdown_read_write

Shuts down the underlying connection, see Socket#shutdown_read_write. A close frame is sent first, unless a frame is being written: the shutdown mustn't wait for a write to a client that stopped reading, and a close frame in the middle of another frame would corrupt it.

Source
unbuffered_close

Closes the wrapped IO.

TODO: Add return type restriction Nil

Source
unbuffered_flush

Flushes the wrapped IO.

TODO: Add return type restriction Nil

Source
unbuffered_read(slice : Bytes) : Int32

Reads at most slice.size bytes from the wrapped IO into slice. Returns the number of bytes read.

TODO: Add return type restriction Int32

Source
unbuffered_rewind

Rewinds the wrapped IO.

TODO: Add return type restriction Nil

Source
unbuffered_write(slice : Bytes) : Nil

Writes slice entirely into the wrapped IO.

TODO: Add return type restriction Nil

Source