Server Sent Events (SSE)

Components

  • There is a separate module for Server Sent Events called SSE and running as a standalone Grizzly Web Server. This server provides for two different sets of clients:
    • Clients subscribing to events
    • Clients that produce events to be broadcast.
  • The REST API provides for subscriptions for the first set of clients and POSTs to broadcast events for the second set of clients.
  • The YouTrack ticket SSE-6 is a good overview of the work to perform event consolidation: https://youtrack.clueride.com/issue/SSE-6
  • To build the SSE server under IntelliJ, see Building SSE Server.
  • To run the SSE server (on dorado or sagitta), see Running SSE Server. The ticket (SSE-4) worked out getting this running as a service (`systemd` sub-system on UNIX).
  • To debug the SSE Server, run in debug mode and connect via IntelliJ. This allows hot swap.
  • To debug the SSE Client, it is helpful to drop breakpoints within the eventsource.js file.
  • SSE Use Cases — Primarily dealing with covering all the bases for the Life Cycle.

About SSE

  • Established once per session to open a single server-sent event channel that carries multiple message types. Subscribing clients should be prepared for any of the events once subscription begins, but there may be expected ordering to the events. It is up to the client to initialize its state properly by requesting state information which may impact the logic of responding to other events — particularly if a client is joining an Outing in progress, for example.
  • The channel itself has a heartbeat which is able to error out if the connection is broken. Heartbeat is a type of "event", but its function is to maintain the channel rather than provide application functionality such as Game State changes, Answer Summary changes, or Award Badge notifications.
  • Reporting on sessions for an outing begins with the establishment of these sessions.

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

Message Types

  • Single channel with different types of messages:
    • Tether — based on a given Outing, the Tether provides a series of LatLon events that tell clients the Guide's position.
    • Game Status — Tracks progress along a given Outing.
    • Puzzle Status — As Answer Summaries for a given Outing's current puzzle are broadcast, clients are given those events.
    • Award Badges — When a badge is awarded, the client is given an opportunity to handle the event and let the user know of the award.
  • SSE Supports Subscribers only for Mobile devices (Is this really just for mobile devices? I seem to be having success picking up the events using the browser.)
  • SSE supports broadcast requests only from Core server

For more detail, see SSE Message Types

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License