A WebRTC signaling server with some other niceties that allow for smooth sailing on the Grooveboat.
As of right now, here's how this event flow should work:
*client connects*
server -> welcome
client -> joinRoom
server -> roomInfo
...
*client is messing around*
client -> ping
server -> pong
*client decides they want a nick change*
client -> setName
server -> changeName (to all client except for the sender)
...
*another client connects elsewhere*
server -> peerJoined
client (new) -> sendTo (the new client begins attempting to peer with users)
*another client leaves*
server -> peerLeft
*client sends a chat*
client -> sendChat
server -> chat (to all client except for the sender)
These are sent to the server by the client.
Changes a client's name
Send data:
{
"e": "setName",
"name": "newName"
}
Sends a chat message to all other clients in the current room
Send data:
{
"e": "sendChat",
"msg": "message text"
}
Tells the server that you are joining a room. The server will eventually respond with a roomData
event.
Send data:
{
"e": "joinRoom",
"roomName": "room name"
"peerName": "a nickname for yourself"
}
Pings the server!
Send data:
{
"e": "ping",
}
Sends a message to another peer (by uuid).
Send data:
{
"e": "sendTo",
"to": "peer uuid"
"msg": { ... }
}
These are events that are received by the peers.
Sent right after the client connects to the server. Provides some simple information about the session.
Send data:
{
"e": "welcome",
"id": "your-uuid",
}
Sent each time a peer joins the current room.
Send data:
{
"e": "peerJoined",
"id": "their-uuid",
}
Sent each time a peer leaves the current room.
Send data:
{
"e": "peerLeft",
"id": "their-uuid",
}
Sent after the client sends the joinRoom
event. Provides information about a room and its peers.
Send data:
{
"e": "roomData",
"name": "room name",
"peers": ["peer-uuid1", "peer-uuid2", ...]
}
Sent when you are receiving a message from another peer.
Data:
{
"e": "recvMessage",
"from": "peer-uuid",
"msg": { ... }
}
Sent when another client sends out a chat.
Send data:
{
"e": "chat",
"msg": "message text"
}
Sent after you ping the server
Data
{
"e": "pong"
}