Longbridge.WSConnection (longbridge v0.1.0)

Copy Markdown View Source

WebSocket connection process for the Longbridge protocol.

Manages a WebSocket connection to a Longbridge endpoint, handling handshake, auth, heartbeat, request/response pairing, and push dispatch.

Wire-format details:

  • Each protocol packet is wrapped as a 32-bit-big-endian length prefix plus payload and sent as a single WebSocket binary message.
  • A single WebSocket binary message may contain multiple length-prefixed packets concatenated together; this module splits them on receive.

Handshake

WebSocket handshake is sent via URL query parameters (?version=1&codec=1&platform=9) per the Longbridge spec, rather than the 2-byte binary handshake used by TCP connections.

Summary

Functions

See Longbridge.Connection.Session.broadcast/2.

See Longbridge.Connection.Session.cancel_idle_timer/1.

See Longbridge.Connection.Session.cancel_reconnect_timer/1.

Returns a specification to start this module under a supervisor.

See Longbridge.Connection.Session.fail_pending_requests/2.

See Longbridge.Connection.Session.next_request_id/1.

See Longbridge.Connection.Session.schedule_idle_timer/1.

See Longbridge.Connection.Session.schedule_reconnect/2.

Functions

broadcast(state, message)

See Longbridge.Connection.Session.broadcast/2.

cancel_idle_timer(state)

See Longbridge.Connection.Session.cancel_idle_timer/1.

cancel_reconnect_timer(state)

See Longbridge.Connection.Session.cancel_reconnect_timer/1.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

fail_pending_requests(state, reason)

See Longbridge.Connection.Session.fail_pending_requests/2.

next_request_id(state)

See Longbridge.Connection.Session.next_request_id/1.

schedule_idle_timer(state)

See Longbridge.Connection.Session.schedule_idle_timer/1.

schedule_reconnect(state, reason)

See Longbridge.Connection.Session.schedule_reconnect/2.