The server is written on the NodeJS engine in the Javascipt language.
The connection to the server takes place using the multi-platform library Socket.io, which was built on the WebSocket technology.
After client success connect to server socket, he must send join event to server with him userdata. If server success compute this request, and connect user to room, he emit joined with room & video data. After that, the server and the client can communicate with any other events.
- Join - Any user connect to server
- Joined - User connected to socket and send his data
- Disc - Any user disconnect from server
- Sync - Server synchronize event
- Play - Any user play video
- Pause - Any user pause video
- Load - Any user load new video link
- Rewind - Any user rewind video to new time
- Message - Any user send chat message
- Light - Any user change light on player
- Click - Any user click on video
- Error Message - Emit on any error from server-side
- Join - User join to player
- Play - User play video
- Pause - User pause video
- Load - User load new video link
- Rewind - User rewind current video to new time
- Message - User send chat message
- Light - User change light on player
- Click - User click on video
All data from server receive on JSON-Object format, not JSON-String.
Receive from the server if new user connected to player room.
{
nick: "NICKNAME",
}
Receive from the server if current user success joined to room and server.
{
video: "VIDEO_ID",
time: 123,
play: true,
light: false
}
video - Video ID (Example: YVcroDDi24s
)
time - is Integer value of video current time play in seconds
play - is Boolean value of video playing status
light - is Boolean value of player light on (true) or off (false)
Receive from the server on user disconnect from room or server.
{
nick: "NICKNAME",
}
Receive from the server info about video play, every 2 min.
{
video: "VIDEO_ID",
time: 123
}
Receive from the server if any user press play.
{
video: "VIDEO_ID",
time: 123,
nick: "NICK_WHO_PRESS_PLAY"
}
Receive from the server if any user press pause.
{
time: 123,
nick: "NICK_WHO_PRESS_PAUSE"
}
Receive from the server if server change video.
{
video: "VIDEO_ID",
nick: "NICK_WHO_PRESS_PAUSE"
}
Receive from the server if any user rewind video.
{
time: 123,
nick: "NICK_WHO_REWIND_VIDEO"
}
Receive from the server new message from users.
{
nick: "NICKNAME",
text: "MESSAGE_TEXT",
color: "#HEX"
}
Receive from the server, if any user click change light button.
{
light: true
}
light - is Boolean value of player light on (true) or off (false)
- true - white mode of player.
- false - dark mode of player.
Receive from the server, if any user click on video.
{
x: 123,
y: 123,
color: "#HEX"
}
x and y - is percent value (0 - 100)
color - user main color and mark color
Receive from the server, on any server-side error.
{
type: "TYPE_ERROR",
message: "MESSAGE_ERROR"
}
All data to server need send on JSON-Object format, not JSON-String.
Send to the server with a successful connection to it (After init socket and on event connect
).
{
nick: "NICKNAME",
room: "ROOMNAME"
}
If server successfully compute you data he emit back "joined" event, else server emit to you "error_message" event
If server receive this event, he emit "join" event to all users
Send to the server what user click play video button.
If server receive this event, he emit "play" event to all users
Send to the server what user click pause video button.
If server receive this event, he emit "pause" event to all users
Send to the server new video link.
{
link: "LINK_TO_YOUTUBE_VIDEO",
playlist: false
}
The playlist property takes two values, true and false.
- True - indicates that the video is selected from a playlist.
- False - indicates that the video is loaded from an external link
If server receive this event, he emit "load" event to all users
Send to the server time in seconds to rewind video.
{
time: 123
}
If server receive this event, he emit "rewind" event to all users
Send new message to the server.
{
text: "MESSAGE_TEXT",
color: "#HEX"
}
Message text can not exceed 150 characters
If server receive this event, he emit "message" event to all users
Send to server if user want change light.
If server receive this event, he emit "light" event to all users
Send to the server, if user click on video.
{
x: 123,
y: 123,
color: "#HEX"
}
x and y - is percent value (0 - 100)
color - user main color and mark color
If server receive this event, he emit "click" event to all users