Server Sent Events

Components

  • There is a separate module for Server Sent Events called SSE and running as a standalone Grizzly Web Server.
  • The YouTrack tickets cover what has been implemented: https://youtrack.clueride.com/issues/SSE
  • To run the SSE server (on sagitta), see Running SSE Server. There is a ticket (SSE-4) for getting this running as a service.

About SSE

  • Established once per session to open a server-sent event channel that carries multiple message types.
  • The channel itself has a heartbeat which is able to error out if the connection is broken.
  • Reporting on sessions for an outing begins with the establishment of these sessions.

Useful link: http://www.programmingwithreason.com/using-sse.html

Types of SSE

  • Single channel with three different types of messages:
    • Heartbeat / Tether
    • Game Status, and
    • Puzzle Status
  • SSE Supports Subscribers only for Mobile devices
  • SSE supports broadcast requests only from Core server

Design Decisions

  • Create separate types of messages and listen for the separate events. (event: customType\n as an example)
  • The state can be represented as CONNECTING: Orange, OPEN: Green, CLOSED: Red.
  • Use a comment (:Keep Alive as an example) to hold the connection open. This is the true heartbeat — keep alive.

Remaining to be explored:

  • Check out the Server Load when multiple clients are subscribing
  • Sort out the Life-cycle of when the channels are brought up and shut down.
  • Reporting on the Server-side which connections are live (may be part of the API for reporting to the Team page).
  • Connectionless Push Notifications — how much of this is built-in already?

Tether (was Heartbeat)

This could be pushed with each position change and then if no new event after a configurable period (20 seconds?), the heartbeat will be sent to confirm connection.

Required Data

  • Event Type Heartbeat
  • GPS coordinates of Guide (tether)
  • Responding to the heartbeat goes back to Connection State on Core Server; absence means loss of connection

Considering the response from clients to confirm the connection is live for each member of the Team (and can be reflected there).

Game State

For a given Outing:

  • Confirming Team (Arrival at Start)
  • Ready to Roll
  • Arrival at next Attraction

Required Data

  • Event Type Game State
  • Outing ID
  • Event Data for Location Change
    • Departing or Arriving
    • When Departing, upcoming Location ID (this is when the next location is revealed)
    • When Arriving, the ID of the location we're arriving at.

Optional Data

  • Timestamp

Puzzle State

For the current puzzle on an outing (up to Core Server to know what this is for the outing)

Required Data

  • Event Type Puzzle State
  • Answer Summaries across team
    • Response total per Answer
    • Total responses

Diagram

This is for the Game State, but the other two are similar.
sse-flow.png
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License