The board stays current through a WebSocket at /tow/board/ws. You will be able to connect a board, read its messages and handle a dropped connection.
Before you start #
- A token for a role with towing access (owner, manager, advisor or dispatcher), with a scope that reaches
/tow. - A WebSocket client. Browsers send no
Authorizationheader on a WebSocket, so this feed signs in a different way.
Steps #
- Open a WebSocket to
/api/v1/tow/board/wsand offer the protocolpsd.board.v1. - Sign in in one of two ways:
- Send
{"type":"auth","token":"<token>"}as the first message, within 10 seconds. - Or offer the extra protocol
psd.token.<token>next topsd.board.v1. A token in the address is ignored, because addresses end up in logs.
- Send
- The server answers
{"type":"ready","now":...,"protocol":"psd.board.v1"}. - Read the messages:
board: a call changed. It carriesevent(call.created,call.assignedorcall.status),call_id,status,atand the call.resync: the connection fell behind. Reload the board withGET /tow/board.pong: the answer to a{"type":"ping"}message you send.error: a refusal, with a code and a message.
- Answer the server's pings. The server pings every 30 seconds and closes a connection that missed the last pong.
Limits and closing #
- A business account can hold 50 open boards. The 51st gets
too_many_connectionsand the close code 1013. - A refusal closes the connection with code 1008: no first message in time, a bad token, a role outside towing or a scope that excludes the board.
- The server re-checks the token on every ping. A revoked token, a deactivated user or a changed role closes the connection with "session ended".
Technical details
- Each business account has its own channel, so one account never sees another account's calls.
- The call in a
boardmessage leaves out the timeline and files to stay small. - Messages that a slow client misses are replaced by one
resync. - The route is public at the HTTP layer and checks the token after the upgrade.
If something goes wrong #
- The connection closes straight after opening: send the
authmessage within 10 seconds. - Close code 1008: check the token, the role and the scope.
- Close code 1013: close another board for this account.
- Missing changes after a network drop: reconnect and call
GET /tow/boardonce.