Skip to content

Latest commit

 

History

History
427 lines (382 loc) · 5.29 KB

websocket-api.md

File metadata and controls

427 lines (382 loc) · 5.29 KB

WebSocket API Reference

Connection

Create room: /api/v1/room/create/ws?username=<required>&color=<required>&avatar-url=<required>&video-url=<required>

Join room: /api/v1/room/{room-id}/join/ws?jwt=<required>&username=<required>&color=<required>&avatar-url=<required>

Messages

Client -> Server

Type Payload
UPDATE_PROFILE
{
  "username": "string",
  "color": "string",
  "avatar_url": "string",
}
PROMOTE_MEMBER
{
  "member_id": "string"
}
REMOVE_MEMBER
{
  "member_id": "string"
}
ADD_VIDEO
{
  "video_url": "string"
}
REMOVE_VIDEO
{
  "video_id": "string"
}
REORDER_PLAYLIST
{
  "videos": [
    {
      "id": "string",
      "url": "string",
      "added_by": "string"
    }
  ],
}
UPDATE_READY
{
  "is_ready": "boolean"
}
UPDATE_MUTED
{
  "is_muted": "boolean"
}
UPDATE_PLAYER_STATE
{
  "playback_rate": "number",
  "is_playing": "boolean",
  "current_time": "number",
  "updated_at": "number"
}
UPDATE_PLAYER_VIDEO
{
  "video_id": "string",
  "updated_at": "number"
}

Server -> Client

Type Payload
JOINED_ROOM
{
  "jwt": "string",
  "room": {
    "room_id": "string",
    "player": {
      "playback_rate": "number",
      "is_playing": "boolean",
      "current_time": "number",
      "updated_at": "number"
    },
    "playlist":{
      "videos": [
        {
          "id": "string",
          "url": "string",
          "added_by": "string"
        }
      ],
      "last_video_id": {
        "id": "string",
        "url": "string",
        "added_by": "string"
      }
    },
    "members": [
      {
        "id": "string",
        "username": "string",
        "color": "string",
        "avatar_url": "string",
        "is_ready": "boolean",
        "is_admin": "boolean",
        "is_muted": "boolean"
      }
    ]
  }
}
PLAYER_STATE_UPDATED
{
  "player": {
    "playback_rate": "number",
    "is_playing": "boolean",
    "current_time": "number",
    "updated_at": "number"
  }
}
PLAYER_VIDEO_UPDATED
{
  "player": {
    "video_url": "string",
    "playback_rate": "number",
    "is_playing": "boolean",
    "current_time": "number",
    "updated_at": "number"
  },
  "playlist":{
    "videos": [
      {
        "id": "string",
        "url": "string",
        "added_by": "string"
      }
    ],
    "last_video_id": {
      "id": "string",
      "url": "string",
      "added_by": "string"
    }
  }
}
VIDEO_ADDED
{
  "added_video": {
    "id": "string",
    "url": "string",
    "added_by": "string"
  },
  "playlist":{
    "videos": [
      {
        "id": "string",
        "url": "string",
        "added_by": "string"
      }
    ],
    "last_video_id": {
      "id": "string",
      "url": "string",
      "added_by": "string"
    }
  }
}
VIDEO_REMOVED
{
  "removed_video_id": "string",
  "playlist":{
    "videos": [
      {
        "id": "string",
        "url": "string",
        "added_by": "string"
      }
    ],
    "last_video_id": {
      "id": "string",
      "url": "string",
      "added_by": "string"
    }
  }
}
PLAYLIST_REORDERED
{
  "videos": [
    {
      "id": "string",
      "url": "string",
      "added_by": "string"
    }
  ],
  "last_video_id": {
    "id": "string",
    "url": "string",
    "added_by": "string"
  }
}
MEMBER_JOINED
{
  "joined_member": {
    "id": "string",
    "username": "string",
    "color": "string",
    "avatar_url": "string",
    "is_ready": "boolean",
    "is_admin": "boolean",
    "is_muted": "boolean"
  },
  "members": [
    {
      "id": "string",
      "username": "string",
      "color": "string",
      "avatar_url": "string",
      "is_ready": "boolean",
      "is_admin": "boolean",
      "is_muted": "boolean"
    }
  ]
}
MEMBER_DISCONNECTED
{
  "disconnected_member_id": "string",
  "members": [
    {
      "id": "string",
      "username": "string",
      "color": "string",
      "avatar_url": "string",
      "is_ready": "boolean",
      "is_admin": "boolean",
      "is_muted": "boolean"
    }
  ]
}
MEMBER_UPDATED
{
  "updated_member": {
    "id": "string",
    "username": "string",
    "color": "string",
    "avatar_url": "string",
    "is_ready": "boolean",
    "is_admin": "boolean",
    "is_muted": "boolean"
  },
  "members": [
    {
      "id": "string",
      "username": "string",
      "color": "string",
      "avatar_url": "string",
      "is_ready": "boolean",
      "is_admin": "boolean",
      "is_muted": "boolean"
    }
  ]
}
IS_ADMIN_CHANGED
{
  "is_admin": "boolean"
}