Some events should only be sent if the player is the host. The server will resend these events with the same name back to all clients. That's when the UI should be updated to reflect room state.
Emit when the host changes the beatmap, accepts a beatmap
structure with artist
, creator
, md5
, and version
(not sure if this is possible to do in the client, if not please let me know). the structure is optional, if omitted the room will turn into a "changing beatmap" state.
Emit when the host of the room was changed, accepts the new host's uid as a string (because 64-bit integer is not possible to represent in javascript lol).
Emit when the host kicks a player, accepts the uid of the player who was kicked.
Emit when the player changes player-specific mods in free mods setting, accepts the new mods as a string. The server will prepend the uid of the player in the parameter when sending the event back to all clients.
Emit when the host changes mods in a non-free mods setting or speed-changing mods in free mods setting. Accepts the new mods as a string.
Emit when the host changes the speed multiplier setting (I only put this event for future support). Accepts the new speed multiplier as a number.
Emit when the host changes the free mod setting. Accepts the new setting state as a boolean.
Emit when the player changes their state. Accepts a number indicating the following information:
- 0: not ready
- 1: ready
- 2: missing beatmap
- 3: playing
The server will prepend the uid of the player in the parameter when sending the event back to all clients.
Emit when the host changes the team mode. Accepts a number indicating the following information:
- 0: head to head (resets the team of all players)
- 1: team vs (sets the team of all players to red)
Emit when the host changes the win condition. Accepts a number indicating the following information:
- 0: score v1
- 1: accuracy
- 2: combo
- 3: score v2
Emit when the player changes their team in Team VS team mode. Accepts the new team as a number indicating the following information:
- 0: red
- 1: blue
The server will prepend the uid of the player in the parameter when sending the event back to all clients.
Emit when the host changes the name of the room. Accepts the new name as a string.
Emit when the host changes the maximum amount of players allowed in the room. Accepts the new maximum amount of players as a number.
Emit when the host initiates gameplay. Does not accept anything for parameter.
Gameplay loading should be started after the client receives this event.
Emit when the player sends a chat message. Accepts the message as a string. The server will prepend the username of the player in the parameter when sending the event back to all clients.
Emit when the player sends a live score data for real-time leaderboard. Accepts the following structure as parameter:
{
score: number;
combo: number;
accuracy: number;
}
The server will send this event back to all clients every 3 seconds, provided that there was data change since the last time the event was sent. It will also include an additional uid
property with type string
in the aforementioned structure to help the client identify players when sending this event back to the client. Keep in mind that the server-to-client event gives an array of the aforementioned structure rather than a single structure.
Emit when the host changes the password of the room. Accepts the new password as a string (optional, if omitted the room is not locked by password).
Emit when the player has finished loading the gameplay after receiving the playBeatmap
event. Does not accept anything for parameter.
Emit when the player requests to skip a portion of the beatmap via the skip button. Does not accept anything for parameter.
Emit for score submission, accepts the following structure:
{
uid: string;
username: string;
modstring: string; // The one that you get from StatisticV2.getModString
score: number;
maxCombo: number;
geki: number; // Amount of `300g`s (StatisticV2.hit300k)
perfect: number; // Amount of 300s
katu: number; // Amount of `100k`s (StatisticV2.hit100k)
good: number; // Amount of 100s
bad: number; // Amount of 50s
miss: number;
}
Emitted when the server encounters an error in processing info (maybe this can be displayed in a toast message). Gives a string as a parameter.
Emitted to a client when it connects to the room socket for the first time. Gives the following room info structure as a parameter.
{
id: number;
name: string;
isLocked: boolean;
maxPlayers: number;
status: number; // 0 = idle, 1 = changing beatmap, 2 = playing
speedMultiplier: number;
mods: string;
isFreeMod: boolean;
teamMode: number; // See teamModeChanged back-to-back event
winCondition: number; // See winConditionChanged back-to-back event
beatmap?: {
artist: string;
creator: string;
md5: string;
version: string;
}; // Omitted when there is no beatmap selected
host: {
uid: string;
username: string;
status: number; // See playerStatusChanged back-to-back event
team: number | null; // null when the team mode is head to head, otherwise see teamChanged back-to-back event
mods: string | null; // Player-specific mods, null in non-free mods setting
};
players: {
uid: string;
username: string;
status: number; // See playerStatusChanged back-to-back event
team: number | null; // null when the team mode is head to head, otherwise see teamChanged back-to-back event
mods: string | null; // Player-specific mods, null in non-free mods setting
}[];
}
Emitted when a player joins the room. Gives the following structure as a parameter:
{
uid: string;
username: string;
status: number; // See playerStatusChanged back-to-back event
team: number | null; // null when the team mode is head to head, otherwise see teamChanged back-to-back event
mods: string | null; // Player-specific mods, null in non-free mods setting
}
Emitted when a socket disconnects from the server (still RFC tbh, ideally the player should not be kicked instantly, will see if socket.io can be configured to use a specific timeout duration). Gives the uid of the disconnected player in a string as a parameter.
Emitted when the status of the room was changed. Gives the new status as a parameter.
Emitted when all players have finished loading the beatmap after all clients receive the playBeatmap
event. Gameplay should only be started after receiving this event. Does not give anything as parameter.
Emitted when all players requested to skip a portion of the beatmap via the skip button. The skip operation should only be performed after receiving this event. Does not give anything as parameter
Emitted when all players have submitted their score. The ranking screen should only be loaded after receiving this event. Gives an array of the score structure mentioned earlier as a parameter (see scoreSubmission
).