Association API drives the bootstrapping of multi-device sessions, being highly dependent on the initial conditions. The starting point only considers the case when the multi-device session involves two devices. However, generalization to a larger number of devices can be done the same way or on a two-by-two basis.
The general functional scenario comprises this behaviour:
- In the beginning, a first device is running some kind of app that is willing to create a multi-device experience.
- The app running on the first device may be a regular Web app that the user is interacting with, or an autostart app triggered by a TV or radio channel.
- After associating, apps running on both devices are from the same origin, so both devices are interacting with the same backend endpoint.
- In the end, the two devices should partake in the same multi-device experience, meaning that the two devices should be able to exchange messages to agree on things.
So there are two main roles:
- Trigger: the application instance that wants to share its session to invite others to join the same experience
- Catcher: the application instance that wants to join with others to the same experience
For instance, both devices could use that channel to exchange the URL of a Shared State in the case of MediaScape, or the first device may use that channel to send control commands to the second.
This way, a set of instances of a MediaScape application, without explicit or implicit user login, running on top of devices could create transparently a shared experience.
These conditions establish a common starting point:
- Both devices are connected or not to the same local area network
- Both devices may access the internet
- An app can be launched on the second device, as opposed to the device just exposing a service endpoint
- The user is the same for both devices
- The user may easily interact with the first device (e.g. enter a code)
- The user may easily interact with the second device (e.g. enter a code)
- Both devices are in close physical proximity
Here you can find an example of implementation: