Mead.Deck.Socket (mead v0.1.1)

Copy Markdown View Source

One WebSocket connection of the deck: a translator between frames and calls on the session's Mead.Deck.Channel, which holds all the state, so a deck that reconnects finds it intact.

The first message must be session.resume; it attaches the socket to the channel, which answers with the snapshot and replays what the deck missed. A socket that has not resumed within resume_deadline_ms is closed (1008), and so is one whose first message is anything else. After that, valid messages go to the channel and the channel's events come back as text frames.

A frame that is binary, too large, not JSON, not an object, of an unknown type or with an invalid payload is ignored and logged by reason only, never by content. More than 20 of them in a minute close the socket (1008). A heartbeat is sent every heartbeat_ms whatever the channel is doing, so a long blocked turn does not look like a dead connection. The heartbeat is followed by a WebSocket ping; any frame from the client, a pong included, counts as activity, and a socket with none for idle_timeout_ms is closed (1001), so a silent client cannot hold it forever.