In Union applications, application state is shared among connected users via room attributes. This example demonstrates how a collaborative presentation-application could use a room attribute, currentSlide, to synchronize and save the current slide in a presentation. When the currentSlide attribute is set, as shown in the following code, it is automatically shared with other occupants in the presentation room and also saved to the server, as follows:
appRoom.setAttribute("currentSlide", newCurrentSlide, true, true);
If the presentation room shuts down because, for example, the meeting is adjourned for the day, the currentSlide is retained in Union Server's data source. The next time the presentation room starts, currentSlide is automatically loaded, and immediately available for use by any client that joins the room.
The example presentation application is shown below. Try opening it in two browser windows to see the shared current slide change in both windows. Then refresh the page to see the saved current slide automatically load.
This application demonstrates the following Orbiter features:
- Creating a room that shuts down when the last occupant leaves
- Joining a room
- Sharing a room attribute
- Saving a room attribute
- Responding to room-attribute updates
Here is the code for the preceding example. Click the "+" button to edit it live on JSFiddle.