128-bit UUID: UserId
, RoomId
, StructureId
, CursorRecordingId
{
"id": RoomId, //Unique room id
"creator": UserId, //The id of the user who created the room,
"title": string, //Room title
"owners": {[id: UserId]: User}, //Map of users who are owners of this room
"structures": {[id: StructureId]: Structure}, //Map of elements on the room
"stylesheet": string //sanitized CSS for the room
}
{
"id" : StructureId,
"creator": UserId,
"pos": //absolute position of the structure [0,1]
{
"x": number,
"y": number
}
"data": StructureData
}
{
"sType": string
//...fields specific to this sType
}
{
"sType": "tunnel",
"sourceId": RoomId, //id of the room that created the tunnel
"targetId": RoomId, //id of the room this tunnel leads to
"sourceText": string, //display text when viewed in the source room
"targetText": string //display text when viewed in the target room
}
{
"id": CursorRecordingId,
"userId": UserId, //id of the user the cursor belongs to
"frames": [{
"pos": //absolute position of the structure [0,1]
{
"x": number,
"y": number
},
"t": number //time step this frame occurred on
]}
}
{
"userId": UserId,
"username": string,
"platformData": PlatformData
}
{
"pType": string
//...fields specific to this pType
}
{
"pType": "desktop",
"cursorPos": //absolute position of the cursor [0,1]
{
"x": number,
"y": number
}
}
{
"pType": "mobile"
}
The Websocket API is separated into two types of interactions--transactions and events.
Transactions have the format described in fresh-socketio-router. The
client emits requests with a specific format and recieves exactly one response from the server, emitted to the same route the
request was made on.
Events are subdivided into Receivable Events and Emittable Events. They have no predefined format, and tend to be "realtime" events, such as mouse movements.
All routes not defined as events or transactions are treated as transaction routes, and will respond with 404 Not Found
.
The body for all transactions and events is a JSON object.
Emitted when the room data was updated.
Body: A room object, containing only fields that were updated.
Emitted when an structure is created on the client's current room.
Body: The newly created structure.
Emitted when an structure is updated on the client's current room.
Body: A structure object, containing the id
and fields that were updated.
Emitted when a user enters the client's current room
Body: The ActiveUser that entered the room.
Emitted when a user leaves the client's current room.
Body: The ActiveUser that left the room.
Emitted when another active user in the room moved their cursor. Body:
{
"userId": UserId,
"pos": {
"x": number,
"y": number
}
}
Should be emitted whenever the client updates their state (e.g. moves their cursor).
Parameters:
{
"pos": {
"x": number,
"y": number
}
}
Clients should issue each request with a unique value for the X-Fresh-Request-Id
header, which will be present in the response headers so responses to the same multiple requests on the same route can be differentiated.
Should be the first event emitted to the server on connection. Contains information about the client's user account, as well as the root room id.
Request parameters: none
Responses:
200
: Object containing user info:
{
"userId": UserId, //the client's userId
"rootRoomId": RoomId //the room id of the root room for all of mazenet
}
Enter a room.
Request:
{
"roomId": RoomId //target room
}
Responses:
200
: Successfully entered room:
{
"room": Room,
"users": {[id: UserId]: ActiveUser} //active users in the room
}
400
: Invalid request404
: Room not found
Update current room data.
Request:
{
"id": RoomId,
"title": string?, //optional
"owners": {[id: UserId]: User}?, //optional
"stylesheet": string? //optional
}
Responses:
200
: Room successfully updated. Responds with a Room object, containing only fields that were updated. Emits a/rooms/updated
event is to all other users in the rooms.400
: Invalid request
Request:
{
"roomId": RoomId,
"structure": Structure //omit the `id` and `creator` fields
}
Responses:
201
: Structure was successfully created. Body contains the new Structure. Emits a/rooms/structures/created
event to all other users in the room.400
: Invalid request
Request: A Structure object containing id
and any fields to be updated.
Responses:
200
: Structure was successfully updated. Body contains the updated Structure. Emits a/rooms/structures/updated
event to all other users in the room.400
: Invalid request
Request:
{
"roomId": RoomId,
"cursorRecordingLimit": number?, //only get the n most recent recordings
"format": "json" | "binary" //specifies the response format
}
Responses:
200
:
{
"cursorRecordings": {[id: CursorRecordingId]: CursorRecording}
}
400
: Invalid request