My journey started with exploring the existing platform. I went through the code of collaboration framework for python version of sugar and got inspiration as to how to approach the problem from scratch. I aimed to mix my ideas with the existing approach.
Then, I exposed myself to Sugarizer. The thing which Sugarizer offered me is Presence API.
Presence API is nothing but a piece of code written to support WebSocket Clients and perform collaborative activities. It was developed by having this collaboration framework in mind. Here is an image explaining how the presence server works.
In order to understand this image, we first need to understand what does client and server mean in this scenario. Client here means the sugar activity and server refers to the presence server hosted at server.sugarizer.org. As one can see, server supports the sharing of activity, joining a shared activity, listing the shared activities, sending message to a group etc.
At this juncture, I would also like to explain two terms which may create confusion if not well understood : Group and Shared Activity.
A group is a group of users who have joined a shared activity. So, A shared activity is shared among a group of users which forms a group.
So, in order to share an activity, client sends message to the server comprising of the details of the user and the activity ID to be shared. The server creates a UUID for this activity, registers it and sends back the UUID to the client which requested to share the activity. Now, if any other client wants to connect to above activity needs to send a message to the server requesting to add it to the list of users for the above shared activity. The client sends the UUID mentioned above to point out the shared activity it wants to join. Since, one cannot know the UUIDs, so they send a message to the server requesting the list of UUIDs of the shared activities and chooses the one which it wants to join.
So, we have shared the activity, listed the shared activities and joined to one.
After joining a shared activity, one only needs to send the message along with the UUID of the group and server broadcasts that message to all the users in that group or all the users who have joined the group.
This is the overview of how the Presence API works.
I hope that I am clear. For any queries, feel free to leave a comment below.