-
Notifications
You must be signed in to change notification settings - Fork 0
ConnectionLifeCycle
Every connection to Yarn comes from a “device.” Devices are laptops, mobile phones, or ipads. All devices
1. Device without a deviceUUID cookie connects to any resource.
2. Login page looks for deviceUUID cookie:
- If it’s not present, creates a new device and assigns the connecting device to this new device object.
- If it’s not present, presents the “choose your user” page.
Given a valid server-side device object, we can map back to what user is logged in at that device. This information is made available to all server-side resources for figuring out who to attribute actions to.
The server pushes messages back to the client using the long poll technique. All clients should have a connection to /connect/ open at all times. When the server has something it wants to send to a client, it looks up the Users or Locations it wants to address, gets a list of the devices owned by those actors, and sends the message to all of them.
When a client receives a message from the server, the server closes the connection after it’s sent a chunk of JSON. It is the client’s responsibility to immediately reconnect to /connect/. If it doesn’t, the server will relatively quickly (doesn’t actually do this yet, but it will soon) mark you as disconnected after a few seconds without a connection.