Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
Emupedia-Bot committed May 14, 2024
1 parent 6293409 commit 577b822
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
4 changes: 2 additions & 2 deletions servers/agarv2/src/commands/CommandList.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CommandList {
constructor(handle) {
this.handle = handle;
/** @type {{[commandName: string]: Command}} */
this.list = { };
this.list = {};
}

/**
Expand Down Expand Up @@ -66,4 +66,4 @@ module.exports = {
}
};

const ServerHandle = require("../ServerHandle");
const ServerHandle = require("../ServerHandle");
24 changes: 6 additions & 18 deletions servers/agarv2/src/commands/DefaultCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ function table(contents, eol) {
}
for (i = 0, rowText = ""; i < contents.columns.length; i++) {
col = contents.columns[i];
rowText += (i == 0 ? "" : col.separated ? " | " : " ") + padRight(col.text, col.headPad, columnSizes[i]);
rowText += (i === 0 ? "" : col.separated ? " | " : " ") + padRight(col.text, col.headPad, columnSizes[i]);
}
all += rowText + eol;
for (i = 0, rowText = ""; i < contents.rows.length; i++, rowText = "") {
for (j = 0; j < contents.rows[i].length; j++) {
row = contents.rows[i][j] || "";
col = contents.columns[j];
rowText += (j == 0 ? "" : col.separated ? " | " : " ") + padRight(row, row ? col.rowPad : col.emptyPad, columnSizes[j]);
rowText += (j === 0 ? "" : col.separated ? " | " : " ") + padRight(row, row ? col.rowPad : col.emptyPad, columnSizes[j]);
}
for (; j < contents.columns.length; j++) {
col = contents.columns[j];
rowText += (j == 0 ? "" : col.separated ? " | " : " ") + padRight("", col.emptyPad, columnSizes[j]);
rowText += (j === 0 ? "" : col.separated ? " | " : " ") + padRight("", col.emptyPad, columnSizes[j]);
}
all += rowText + eol;
}
Expand Down Expand Up @@ -685,11 +685,7 @@ module.exports = (commands, chatCommands) => {
const list = handle.chatCommands.list;
handle.listener.globalChat.directMessage(null, context, "available commands:");
for (let name in list)
handle.listener.globalChat.directMessage(
null,
context,
`${name}${list[name].args.length > 0 ? " " : ""}${list[name].args} - ${list[name].description}`
);
handle.listener.globalChat.directMessage(null, context, `${name}${list[name].args.length > 0 ? " " : ""}${list[name].args} - ${list[name].description}`);
}
}),
genCommand({
Expand All @@ -700,11 +696,7 @@ module.exports = (commands, chatCommands) => {
* @param {Connection} context
*/
exec: (handle, context, args) => {
handle.listener.globalChat.directMessage(
null,
context,
context.hasPlayer ? `your ID is ${context.player.id}` : "you don't have a player associated with yourself"
);
handle.listener.globalChat.directMessage(null, context, context.hasPlayer ? `your ID is ${context.player.id}` : "you don't have a player associated with yourself");
}
}),
genCommand({
Expand All @@ -720,11 +712,7 @@ module.exports = (commands, chatCommands) => {
return void chat.directMessage(null, context, "you don't have a player associated with yourself");
if (!context.player.hasWorld)
return void chat.directMessage(null, context, "you're not in a world");
chat.directMessage(
null,
context,
`your world ID is ${context.player.world.id}`
);
chat.directMessage(null, context, `your world ID is ${context.player.world.id}`);
}
}),
genCommand({
Expand Down
25 changes: 25 additions & 0 deletions servers/protocols/websocket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# WebSocket close codes

| Close code (uint16) | Codename | Internal | Customizable | Description |
|---------------------|------------------------|----------|--------------|-------------|
| 0 - 999 | | Yes | No | Unused |
| 1000 | `CLOSE_NORMAL` | No | No | Successful operation / regular socket shutdown |
| 1001 | `CLOSE_GOING_AWAY` | No | No | Client is leaving (browser tab closing) |
| 1002 | `CLOSE_PROTOCOL_ERROR` | Yes | No | Endpoint received a malformed frame |
| 1003 | `CLOSE_UNSUPPORTED` | Yes | No | Endpoint received an unsupported frame (e.g. binary-only endpoint received text frame) |
| 1004 | | Yes | No | Reserved |
| 1005 | `CLOSED_NO_STATUS` | Yes | No | Expected close status, received none |
| 1006 | `CLOSE_ABNORMAL` | Yes | No | No close code frame has been receieved |
| 1007 | *Unsupported payload* | Yes | No | Endpoint received inconsistent message (e.g. malformed UTF-8) |
| 1008 | *Policy violation* | No | No | Generic code used for situations other than 1003 and 1009 |
| 1009 | `CLOSE_TOO_LARGE` | No | No | Endpoint won't process large frame |
| 1010 | *Mandatory extension* | No | No | Client wanted an extension which server did not negotiate |
| 1011 | *Server error* | No | No | Internal server error while operating |
| 1012 | *Service restart* | No | No | Server/service is restarting |
| 1013 | *Try again later* | No | No | Temporary server condition forced blocking client's request |
| 1014 | *Bad gateway* | No | No | Server acting as gateway received an invalid response |
| 1015 | *TLS handshake fail* | Yes | No | Transport Layer Security handshake failure |
| 1016 - 1999 | | Yes | No | Reserved for later |
| 2000 - 2999 | | Yes | Yes | Reserved for websocket extensions |
| 3000 - 3999 | | No | Yes | Registered first come first serve at IANA |
| 4000 - 4999 | | No | Yes | Available for applications |

0 comments on commit 577b822

Please sign in to comment.