Skip to content
seandlg edited this page Apr 17, 2020 · 10 revisions

API

The following API is in place. Changes will be documented in this Wiki.

Server

Servers must act on the following instructions.

Join a party instruction

A client wishes to join a party. He thereby subscribes to video updates (play, pause, seek) & party state updates (e.g. when somebody joins or leaves the party).

{
   "type":"join",
   "data":{
      "guid":"client-guid",
      "partyId":"someId",
      "clientState":{
         "clientName":"guest",
         "currentlyWatching":"www.example.com"
      }
   }
}

Leaving a party is handled when a Websocket closes. There is no specific instruction to leave a party.

Forward instruction

The server may be asked to forward a instruction to all clients of a given party. Valid variants for videoUpdate are play, pause & seek.

{
   "type":"forward",
   "data":{
      "commandToForward":{
         "type":"videoUpdate",
         "data":{
            "variant":"play",
            "tick":1000
         }
      }
   }
}

Client Update Instruction

Clients can send this instruction, if they wish to update their client state.

{
   "type":"clientUpdate",
   "data":{
      "newClientState":{
         "currentlyWatching":"www.youtube.com"
      }
   }
}

Clients

Clients must act on the following instructions:

Video Update Instruction

The server can tell clients to play, pause or seek within the context of the video currently present in the client's tab's DOM.

{
   "type":"videoUpdate",
   "data":{
      "variant":"playPause",
      "tick":1000,
      "peer":{
         "uuid":"client-party-uuid",
         "clientName":"clientXYZ",
         "currentlyWatching":"www.youtube.com"
      }
   }
}

Party State Update Instruction

The server can instruct clients to update their party state. Among other things, this tells the client which peers are currently present in the party and what Website they're currently on.

{
   "type":"partyStateUpdate",
   "data":{
      "partyState":{
         "isActive":true,
         "partyId":"someId",
         "peers":[
            {
               "uuid":"client-party-uuid",
               "clientName":"clientXYZ",
               "currentlyWatching":"www.youtube.com"
            }
         ]
      }
   }
}
Clone this wiki locally