Activities are the most important way of communication to keep a Shared Session consistent.
The following Diagram shows how Activities are sent by clients in Saros. Notice that the Host also acts as a Client for locally created Activities.
New Activities are created by the Activity Providers. They take actions of the local user and transform them to Activities. As Activity Providers are registered at the Session Management the Activity Handling gets informed about the new Activity and sets the Host as target for this Activity. If the Activity is Jupiter related it will first be passed to the Concurrency Management where it will be transformed.
Afterward the Activity will be passed to the Activity Sequencer where it will be queued and also gets a timestamp to ensure a global ordering of Activities. The OutgoingActivityQueue is polled frequently and the Activities will then be passed to the ITransmitter where they are transformed into XMPP-messages and transmitted to the Host.
All Clients send their Activities to the Server located at the Host. The following diagram shows how the Server handles and directs incoming Activities.
Every participant receives Activities via the IReceiver. The IReceiver allows other components to register packetListeners that will be informed when Messages with a specific PackageExtension arrive. The Activity Sequencer also registers such a listener and will be informed when new Activities arrive. The Activity Sequencer checks that the Activity has the right sequence-number and if so passes it to the Activity Handling.
The Activity Handling distinguishes between three different types of Activities:
- Jupiter related Activity: Activities that are related to the Jupiter-Algorithm will be passed to the Concurrency Management where they will be transformed into an Activity with a different timestamps for each participant. Every participants gets a separate Activity and is set as its receiver.
- ITargetedActivity: When processing an ITargetedActivity the receiver will be set as the target of the Activity.
- Others: The receivers of all other Activities are all participants except the creator of the Activity.
After setting the right receivers the Activities will again be send to the ITransmitter, via the Activity Sequencer, and transmitted to the intended receivers.
After the Server has distributed the Activities all intended Clients receive them. Again, remember that the Host also acts as a Client despite housing the Server. The following diagram shows how the receiving works.
When a new Activity arrives the Activity Sequencer will be informed about this and passes the Activity to the Activity Handling.
The Activity Handling passes incoming Activities to the Concurrency Control if needed. For example a JupiterActivity will be transformed back into a TextEditActivity. Afterwards the Activitiy Handling informs all registered Activity Providers about the new Activity. Every Activity Provider checks himself if he is responsible for this type of Activity. If responsible the Activity Provider transforms the Activity back into an action, that can be applied to the local Saros-Instance and executes this action.