documentation-updates #1
3 changed files with 215 additions and 499 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019-2023 flashwave
|
Copyright (c) 2019-2024 flashwave
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
707
Protocol.md
707
Protocol.md
|
@ -12,68 +12,55 @@ Further documentation on their behaviour will be added at a later date.
|
||||||
### `bool`
|
### `bool`
|
||||||
A value that indicates a true or a false state. `0` represents false and anything non-`0` represents true, please stick to `1` for representing true though.
|
A value that indicates a true or a false state. `0` represents false and anything non-`0` represents true, please stick to `1` for representing true though.
|
||||||
|
|
||||||
|
|
||||||
### `int`
|
### `int`
|
||||||
Any number ranging from `-9007199254740991` to `9007199254740991`, `Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER` in JavaScript.
|
Any number ranging from `-9007199254740991` to `9007199254740991`, `Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER` in JavaScript.
|
||||||
|
|
||||||
|
|
||||||
### `string`
|
### `string`
|
||||||
Any printable unicode character, except `\t` which is used to separate packets.
|
Any printable unicode character, except `\t` which is used to separate packets.
|
||||||
|
|
||||||
|
|
||||||
### `timestamp`
|
### `timestamp`
|
||||||
Extends `int`, contains a second based UNIX timestamp.
|
Extends `int`, contains a second based UNIX timestamp.
|
||||||
|
|
||||||
|
### `user name`
|
||||||
|
A `string` containing a user's name.
|
||||||
|
|
||||||
|
If the user currently has an AFK tag set through the `/afk`, it is prefixed by `<AFK>_`.
|
||||||
|
The `AFK` text can be replaced by any text supplied to the `/afk` command as an argument, the original PHP Sock Chat and SharpChat force this text to uppercase and limit it to 5 characters.
|
||||||
|
|
||||||
|
If prefixed by a `~`, it is not the user's actual name but a nick name.
|
||||||
|
|
||||||
### `channel name`
|
### `channel name`
|
||||||
A `string` containing only alphanumeric characters (any case), `-` or `_`.
|
A `string` containing only alphanumeric characters (any case), `-` or `_`.
|
||||||
|
|
||||||
|
### `colour`
|
||||||
### `color`
|
Any valid value for the CSS `colour` property.
|
||||||
Any valid value for the CSS `color` property.
|
|
||||||
Further documentation can be found [on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
Further documentation can be found [on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
||||||
|
|
||||||
|
|
||||||
### `message flags`
|
### `message flags`
|
||||||
Message flags alter how a message should be displayed to the client, these are all `bool` values.
|
Message flags alter how a message should be displayed to the client, these are all `bool` values.
|
||||||
The parts are as follows:
|
The parts are as follows:
|
||||||
|
|
||||||
- Username should appear using a **bold** font.
|
- Username should appear using a **bold** font.
|
||||||
- Username should appear using a *cursive* font.
|
- Username should appear using a *cursive* font.
|
||||||
- Username should appear __underlined__.
|
- Username should appear <u>underlined</u>.
|
||||||
- A colon `:` should be displayed between the username and the message.
|
- A colon `:` should be displayed between the username and the message.
|
||||||
- The message was sent privately, directly to the current user.
|
- The message was sent privately, directly to the current user.
|
||||||
|
|
||||||
As an example, the most common message flagset is `10010`. This indicates a bold username with a colon separator.
|
As an example, the most common message flagset is `10010`. This indicates a bold username with a colon separator.
|
||||||
|
|
||||||
|
### `user perms`
|
||||||
### `user permissions`
|
User permissions are a set of flags separated by either the form feed character (`\f` / `0x0C`) or a space (' ' / `0x20`).
|
||||||
User permissions are a set of flags separated by either the form feed character (`\f` / `0x0C`) or a space (<code> </code> / `0x20`).
|
|
||||||
The reason there are two options is due to a past mixup that we now have to live with.
|
The reason there are two options is due to a past mixup that we now have to live with.
|
||||||
Which of the methods is used remains consistent per server however, so the result of a test can be cached.
|
Which of the methods is used remains consistent per server however, so the result of a test can be cached.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:------:| ----------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Rank of the user. Used to determine what channels a user can access or what other users the user can moderate. |
|
||||||
<td>Rank of the user. Used to determine what channels a user can access or what other users the user can moderate.</td>
|
| `bool` | Indicates whether the user the ability kick/ban/unban others. |
|
||||||
</tr>
|
| `bool` | Indicates whether the user can access the logs. This should always be `0`, unless the client has a dedicated log view that can be accessed without connecting to the chat server. |
|
||||||
<tr>
|
| `bool` | Indicates whether the user can set an alternate display name. |
|
||||||
<td><code>bool</code></td>
|
| `int` | Indicates whether the user can create channel. If `0` the user cannot create channels, if `1` the user can create channels but they are to disappear when all users have left it and if `2` the user can create channels that permanently stay in the channel assortment. |
|
||||||
<td>Indicates whether the user the ability kick/ban/unban others.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the user can access the logs. This should always be <code>0</code>, unless the client has a dedicated log view that can be accessed without connecting to the chat server.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the user can set an alternate display name.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>int</code></td>
|
|
||||||
<td>Indicates whether the user can create channel. If <code>0</code> the user cannot create channels, if <code>1</code> the user can create channels but they are to disappear when all users have left it and if <code>2</code> the user can create channels that permanently stay in the channel assortment.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
## Client Packets
|
## Client Packets
|
||||||
|
@ -82,23 +69,35 @@ These are the packets sent from the client to the server.
|
||||||
### Packet `0`: Ping
|
### Packet `0`: Ping
|
||||||
Used to prevent the client from closing the session due to inactivity.
|
Used to prevent the client from closing the session due to inactivity.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the current user. |
|
||||||
<td>User ID</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `1`: Authentication
|
### Packet `1`: Authentication
|
||||||
Takes a variable number of parameters that are fed into the authentication script associated with the chat.
|
Takes a variable number of parameters that are fed into the authentication script associated with the chat.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----------:| ----------- |
|
||||||
<td><code>...string</code></td>
|
| `...string` | Any amount of data required to complete authentication. |
|
||||||
<td>Any amount of data required to complete authentication</td>
|
|
||||||
</tr>
|
#### Original Sock Chat phpBB format
|
||||||
</table>
|
Although the specification was never strict on the format, the original client and server combo included only a single authentication extension for phpBB.
|
||||||
|
Flashii Hajime, Sakura and early Misuzu also used this same format.
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
|:--------:| ----------- |
|
||||||
|
| `string` | User ID of the authenticating user. |
|
||||||
|
| `string` | Session token for the authenticating user. |
|
||||||
|
|
||||||
|
#### Flashii Chat format
|
||||||
|
In order to support multiple authentication methods more easily, Flashii Chat currently uses a format similar to the HTTP Authorization header, where the first field is the authentication method and the second field is the authentication token.
|
||||||
|
Previously, this was achieved using prefixes to the session token part of phpBB format.
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
|:--------:| ----------- |
|
||||||
|
| `string` | Authentication method, for example `Bearer` for an OAuth2 bearer token, or `Misuzu` for using the `msz_auth` cookie value. |
|
||||||
|
| `string` | Authentication token, for example the OAuth2 bearer token value, or the Misuzu authentication cookie. |
|
||||||
|
|
||||||
|
|
||||||
### Packet `2`: Message
|
### Packet `2`: Message
|
||||||
|
@ -106,16 +105,10 @@ Informs the server that the user has sent a message.
|
||||||
|
|
||||||
Commands are described lower in the document.
|
Commands are described lower in the document.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the current user. |
|
||||||
<td>User ID</td>
|
| `string` | Message text, cannot contain a tab character `\t`. |
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message text, may not contain <code>\t</code></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
## Server Packets
|
## Server Packets
|
||||||
|
@ -124,12 +117,9 @@ These are the packets sent from the server to the client.
|
||||||
### Packet `0`: Pong
|
### Packet `0`: Pong
|
||||||
Response to client packet `0`: Ping.
|
Response to client packet `0`: Ping.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | A string containing `pong`. Previously SharpChat sent the current Unix timestamp here, but has since been updated to conform to the Original Sock Chat server formatting. |
|
||||||
<td>Any arbitrary string, do not rely on the data sent here. Original Sock Chat server sent <code>pong</code>, SharpChat currently sends the current Unix epoch timestamp in seconds.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `1`: Join/Auth
|
### Packet `1`: Join/Auth
|
||||||
|
@ -138,532 +128,255 @@ While authenticated this packet indicates that a new user has joined the server/
|
||||||
#### Successful authentication response
|
#### Successful authentication response
|
||||||
Informs the client that authentication has succeeded.
|
Informs the client that authentication has succeeded.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | `y` to indicate a successful authentication attempt. |
|
||||||
<td><code>y</code></td>
|
| `string` | User ID of the authenticated user. |
|
||||||
</tr>
|
| `user name` | User name of the authenticated user. |
|
||||||
<tr>
|
| `colour` | User colour of the authenticated user. |
|
||||||
<td><code>string</code></td>
|
| `user perms` | Permissions for the authenticated user. |
|
||||||
<td>User ID</td>
|
| `channel name` | Default channel the user will join following this packet. |
|
||||||
</tr>
|
| `int` | Maximum length for messages sent by the client. NOTE: While the original PHP server did not send this data, the bundled client did look for it. |
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>color</code></td>
|
|
||||||
<td>Username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>channel name</code></td>
|
|
||||||
<td>Default channel the user will join following this packet</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>int</code></td>
|
|
||||||
<td>Maximum length for messages sent by the client</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Failed authentication response
|
#### Failed authentication response
|
||||||
Informs the client that authentication has failed.
|
Informs the client that authentication has failed.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | `n` to indicate a failed authentication attempt. |
|
||||||
<td><code>n</code></td>
|
| `string` | A reason string indicating the reason why the authentication attempt failed, options are listed below. |
|
||||||
</tr>
|
| `timestamp` | If included, indicates a ban expiration timestamp. Usually paired with the `joinfail` reason string. |
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>
|
|
||||||
Reason for failure.
|
|
||||||
<ul>
|
|
||||||
<li><code>authfail</code>: Authentication data is invalid.</li>
|
|
||||||
<li><code>userfail</code>: Username in use.</li>
|
|
||||||
<li><code>sockfail</code>: A connection has already been started (used to cap maximum connections to 5 in SharpChat).</li>
|
|
||||||
<li><code>joinfail</code>: User attempting to authenticate is banned.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>timestamp</code></td>
|
|
||||||
<td>If <code>joinfail</code> this contains expiration time of the ban, otherwise it is empty.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
##### Reason strings
|
||||||
|
| Reason | Explanation |
|
||||||
|
| ---------- | ----------- |
|
||||||
|
| `authfail` | Provided authentication data cannot be verified with an existing user or session. |
|
||||||
|
| `joinfail` | Authentication data was correct, but the user is banned. The third field will contain an expiration timestamp. |
|
||||||
|
| `sockfail` | Current socket connection is already authenticated. PHP Chat did not allow the same user account to be in chat more than once. SharpChat allows simultaneous connections, so this is used to put a cap on the maximum amount of connections a single user may have. As of writing this, the maximum number is `5`, however this may change in the future. |
|
||||||
|
| `userfail` | A user with the same user name is already in chat. PHP Chat did not allow the same user account to be in chat more than once. SharpChat allows simultaneous connections, so this is used as a generic fallback reason in that implementation. If it occurs, a critical error happened on the backend. |
|
||||||
|
|
||||||
#### User joining
|
#### User joining
|
||||||
Informs the client that a user has joined.
|
Informs the client that a user has joined.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:------------:| ----------- |
|
||||||
<td><code>timestamp</code></td>
|
| `timestamp` | Timestamp at which the user joined. |
|
||||||
<td>Time the user joined</td>
|
| `string` | User ID of the joining user. |
|
||||||
</tr>
|
| `user name` | User name of the joining user. |
|
||||||
<tr>
|
| `colour` | User colour for the joining user. |
|
||||||
<td><code>string</code></td>
|
| `user perms` | Permissions for the joining user. |
|
||||||
<td>User ID</td>
|
| `string` | Message ID associated with this event. |
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>colour</code></td>
|
|
||||||
<td>Username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `2`: Chat message
|
### Packet `2`: Chat message
|
||||||
Informs the client that a chat message has been received.
|
Informs the client that a chat message has been received.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:---------------:| ----------- |
|
||||||
<td><code>timestamp</code></td>
|
| `timestamp` | Timestamp at which the message was received by the server. |
|
||||||
<td>Time when the message was received by the server</td>
|
| `string` | User ID of the author. If `-1` the message body will contain a formatted informational message documented below. |
|
||||||
</tr>
|
| `string` | Message body. If this isn't an informational message, it is sanitised by the server: `<`, `>` and `\n` are replaced by `<`, `>` and ` <br/> `. SharpChat also replaces `\t` with four sequential space characters. |
|
||||||
<tr>
|
| `string` | Message ID. |
|
||||||
<td><code>string</code></td>
|
| `message flags` | Message flags. |
|
||||||
<td>
|
|
||||||
User ID.
|
#### Informational message formatting
|
||||||
If <code>-1</code> this message is an informational message from the server and the next field takes on a special form.
|
If this is an informational message this field is formatted as follows and concatenated by the form feed character `\f`, respresented in ASCII by `0x0C`.
|
||||||
</td>
|
Bot message formats are described lower in the document.
|
||||||
</tr>
|
|
||||||
<tr>
|
| Type | Description |
|
||||||
<td><code>string</code></td>
|
|:-----------:| ----------- |
|
||||||
<td>
|
| `bool` | If `1`, this message should be displayed as an error message. If `0`, it should be displayed as a normal informational message. |
|
||||||
<p>Message, sanitised by the server</p>
|
| `string` | Informational message format name. List of formats is described below. |
|
||||||
<p>
|
| `...string` | Any number of parameters required by the format string. |
|
||||||
If this is an informational message this field is formatted as follows and concatenated by the form feed character <code>\f</code>, respresented in ASCII by <code>0x0C</code>. Bot message formats are described lower in the document.
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><code>int</code></td>
|
|
||||||
<td>
|
|
||||||
Message type.
|
|
||||||
<ul>
|
|
||||||
<li><code>0</code> for a normal informational message.</li>
|
|
||||||
<li><code>1</code> for an error.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>An id of a string in the legacy language files.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>...string</code></td>
|
|
||||||
<td>Any number of parameters used to format the language string.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>message flags</code></td>
|
|
||||||
<td>Message flags</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `3`: User disconnect
|
### Packet `3`: User disconnect
|
||||||
Informs the client that a user has disconnected.
|
Informs the client that a user has disconnected.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the disconnecting user. |
|
||||||
<td>User ID</td>
|
| `user name` | User name of the disconnecting user. |
|
||||||
</tr>
|
| `string` | Reason for disconnecting, described below. |
|
||||||
<tr>
|
| `timestamp` | Timestamp when the user disconnected. |
|
||||||
<td><code>string</code></td>
|
| `string` | Message ID associated with this event. |
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
#### Disconnect reasons
|
||||||
<tr>
|
| Reason | Explanation |
|
||||||
<td><code>string</code></td>
|
| --------- | ----------- |
|
||||||
<td>
|
| `leave` | User gracefully left, e.g. "xyz logged out". |
|
||||||
One of four disconnect reasons.
|
| `kick` | User got banned, kicked or otherwise unvoluntarily had their session terminated, e.g. "xyz has been kicked". |
|
||||||
<ul>
|
| `flood` | User got kicked for exceeding the flood protection limit, e.g. "xyz has been kicked for spam". |
|
||||||
<li><code>leave</code>: The user gracefully left, e.g. "x logged out".</li>
|
| `timeout` | User lost connection unexpectedly after not sending pings in a timely fashion, e.g. "xyz timed out". The original PHP Sock Chat implementation did not support this and was added later by SharpChat. Support could be added by modifying the language file, so we're letting this slide. |
|
||||||
<li><code>timeout</code>: The user lost connection unexpectedly, e.g. "x timed out".</li>
|
|
||||||
<li><code>kick</code>: The user has been kicked, e.g. "x has been kicked".</li>
|
|
||||||
<li><code>flood</code>: The user has been kicked for exceeding the flood protection limit, e.g. "x has been kicked for spam".</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>timestamp</code></td>
|
|
||||||
<td>Time when the user disconnected</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `4`: Channel event
|
### Packet `4`: Channel event
|
||||||
This packet informs the user about channel related updates. The only consistent parameter across sub-packets is the first one described as follows.
|
This packet informs the user about channel related updates.
|
||||||
|
The only consistent parameter across sub-packets is the first one described as follows.
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><code>int</code></td>
|
|
||||||
<td>
|
|
||||||
Channel information update event ID.
|
|
||||||
<ul>
|
|
||||||
<li><code>0</code>: A channel has been created.</li>
|
|
||||||
<li><code>1</code>: A channel has been updated.</li>
|
|
||||||
<li><code>2</code>: A channel has been deleted.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
|:-----:| -------------- |
|
||||||
|
| `int` | Sub-packet ID. |
|
||||||
|
|
||||||
#### Sub-packet `0`: Channel creation
|
#### Sub-packet `0`: Channel creation
|
||||||
Informs the client that a channel has been created.
|
Informs the client that a channel has been created.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------------:| ----------- |
|
||||||
<td><code>channel name</code></td>
|
| `channel name` | Name of the new channel. |
|
||||||
<td>The name of the new channel</td>
|
| `bool` | Indicates whether the channel is password protected (non-`0`) or not (`0`). |
|
||||||
</tr>
|
| `bool` | Indicates whether the channel is temporary (non-`0`) or not (`0`). In the original PHP Chat implementation this would mean a channel gets deleted after the last person departs from it. |
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is password protected</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is temporary, meaning the channel will be deleted after the last person departs</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `1`: Channel update
|
#### Sub-packet `1`: Channel update
|
||||||
Informs the client that details of a channel has changed.
|
Informs the client that details of a channel has changed.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------------:| ----------- |
|
||||||
<td><code>channel name</code></td>
|
| `channel name` | Previous name of the channel. |
|
||||||
<td>Old/current name of the channel</td>
|
| `channel name` | New name of the channel. |
|
||||||
</tr>
|
| `bool` | Indicates whether the channel is password protected (non-`0`) or not (`0`). |
|
||||||
<tr>
|
| `bool` | Indicates whether the channel is temporary (non-`0`) or not (`0`). In the original PHP Chat implementation this would mean a channel gets deleted after the last person departs from it. |
|
||||||
<td><code>channel name</code></td>
|
|
||||||
<td>New name of the channel</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is password protected</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is temporary, meaning the channel will be deleted after the last person departs</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `2`: Channel deletion
|
#### Sub-packet `2`: Channel deletion
|
||||||
Informs the client that a channel has been deleted
|
Informs the client that a channel has been deleted
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------------:| ----------- |
|
||||||
<td><code>channel name</code></td>
|
| `channel name` | Name of the channel to be deleted. |
|
||||||
<td>Name of the channel that has been deleted</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `5`: Channel switching
|
### Packet `5`: Channel switching
|
||||||
This packet informs the client about channel switching.
|
This packet informs the client about channel switching.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----:| -------------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Sub-packet ID. |
|
||||||
<td>
|
|
||||||
Channel information update event ID.
|
|
||||||
<ul>
|
|
||||||
<li><code>0</code>: A user joined the channel. Sent to all users in said channel.</li>
|
|
||||||
<li><code>1</code>: A user left the channel. Sent to all users in said channel.</li>
|
|
||||||
<li><code>2</code>: The client is to forcibly join a channel.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `0`: Channel join
|
#### Sub-packet `0`: Channel join
|
||||||
Informs the client that a user has joined the channel.
|
Informs the client that a user has joined the channel.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:------------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the user joining the channel. |
|
||||||
<td>User ID</td>
|
| `user name` | User name of the user joining the channel. |
|
||||||
</tr>
|
| `colour` | User colour of the user joining the channel. |
|
||||||
<tr>
|
| `user perms` | Permissions of the user joining the channel. |
|
||||||
<td><code>string</code></td>
|
| `string` | Message ID associated with this event. |
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>color</code></td>
|
|
||||||
<td>Username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `1`: Channel departure
|
#### Sub-packet `1`: Channel departure
|
||||||
Informs the client that a user has left the channel.
|
Informs the client that a user has left the channel.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:------------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the user leaving the channel. |
|
||||||
<td>User ID</td>
|
| `string` | Message ID associated with this event. |
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `2`: Forced channel switch
|
#### Sub-packet `2`: Forced channel switch
|
||||||
Informs the client that it has been forcibly switched to a different channel.
|
Informs the client that it has been forcibly switched to a different channel.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------------:| ----------- |
|
||||||
<td><code>channel name</code></td>
|
| `channel name` | Name of the channel the current user is now present in. |
|
||||||
<td>The name of the channel that the user has been switched to</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `6`: Message deletion
|
### Packet `6`: Message deletion
|
||||||
Informs the client that a message has been deleted.
|
Informs the client that a message has been deleted.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:--------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | Message ID of the message to be deleted. |
|
||||||
<td>Message ID of the deleted message</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `7`: Context information
|
### Packet `7`: Context information
|
||||||
Informs the client about the context of a channel before the client was present.
|
Informs the client about the context of a channel before the client was present.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----:| -------------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Sub-packet ID. |
|
||||||
<td>
|
|
||||||
Context event ID.
|
|
||||||
<ul>
|
|
||||||
<li><code>0</code>: Users present in the current channel.</li>
|
|
||||||
<li><code>1</code>: A message already in the channel, occurs more than once per channel.</li>
|
|
||||||
<li><code>2</code>: Channels on the server.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
#### Sub-packet `0`: Existing users
|
#### Sub-packet `0`: Existing users
|
||||||
Informs the client about users already present in the channel.
|
Informs the client about users already present in the channel.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----:| ----------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Amount of users present in the current channel. |
|
||||||
<td>Amount of users present in the channel</td>
|
| | A repetition of a number of fields based on the number above, described below. |
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>Context User</code></td>
|
|
||||||
<td>An amount of repetitions of this object based on the number in the previous param, the object is described below</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
##### Context User object
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>User ID</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>color</code></td>
|
|
||||||
<td>Username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Whether the user should be visible in the users list</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
##### Context user information
|
||||||
|
| Type | Description |
|
||||||
|
|:------------:| ----------- |
|
||||||
|
| `string` | User ID of this already present user. |
|
||||||
|
| `user name` | User name of this already present user. |
|
||||||
|
| `colour` | User colour of this already present user. |
|
||||||
|
| `user perms` | Permissions of this already present user. |
|
||||||
|
| `bool` | If non-`0` this user should be displayed in a user list, if `0` this user should be treated as invisible. Used by bot mods in the original PHP implementation. |
|
||||||
|
|
||||||
#### Sub-packet `1`: Existing message
|
#### Sub-packet `1`: Existing message
|
||||||
Informs the client about an existing message in a channel.
|
Informs the client about an existing message in a channel.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:---------------:| ----------- |
|
||||||
<td><code>timestamp</code></td>
|
| `timestamp` | Timestamp at which the message was received by the server. |
|
||||||
<td>Time when the message was received by the server</td>
|
| `string` | User ID of the author. If `-1` the message body will contain a formatted informational message documented below. |
|
||||||
</tr>
|
| `user name` | User name of the author of this message. |
|
||||||
<tr>
|
| `colour` | User colour of the author of this message. |
|
||||||
<td><code>string</code></td>
|
| `user perms` | Permissions of the author of this message. |
|
||||||
<td>User ID</td>
|
| `string` | Message body. If this isn't an informational message, it is sanitised by the server: `<`, `>` and `\n` are replaced by `<`, `>` and ` <br/> `. SharpChat also replaces `\t` with four sequential space characters. |
|
||||||
</tr>
|
| `string` | Message ID. |
|
||||||
<tr>
|
| `bool` | If non-`0` this message should trigger notifications (sounds, banners, etc) on the client. |
|
||||||
<td><code>string</code></td>
|
| `message flags` | Message flags. |
|
||||||
<td>Username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>color</code></td>
|
|
||||||
<td>Username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message text, functions the same as described in Packet <code>2</code>: Chat message</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>Message ID</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Whether the client should notify the user about this message</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>message flags</code></td>
|
|
||||||
<td>Message flags</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
#### Sub-packet `2`: Channels
|
#### Sub-packet `2`: Channels
|
||||||
Informs the client about the channels on the server.
|
Informs the client about the channels on the server.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----:| ----------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Amount of channels on the server. |
|
||||||
<td>Amount of channels on the channel</td>
|
| | A repetition of a number of fields based on the number above, described below. |
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>Context Channel</code></td>
|
|
||||||
<td>An amount of repetitions of this object based on the number in the previous param, the object is described below</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
##### Context Channel object
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><code>channel name</code></td>
|
|
||||||
<td>Name of the channel</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is password protected</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>bool</code></td>
|
|
||||||
<td>Indicates whether the channel is temporary, meaning the channel will be deleted after the last person departs</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
##### Context channel information
|
||||||
|
| Type | Description |
|
||||||
|
|:--------------:| ----------- |
|
||||||
|
| `channel name` | Name of the new channel. |
|
||||||
|
| `bool` | Indicates whether the channel is password protected (non-`0`) or not (`0`). |
|
||||||
|
| `bool` | Indicates whether the channel is temporary (non-`0`) or not (`0`). In the original PHP Chat implementation this would mean a channel gets deleted after the last person departs from it. |
|
||||||
|
|
||||||
### Packet `8`: Context clearing
|
### Packet `8`: Context clearing
|
||||||
Informs the client that the context has been cleared.
|
Informs the client that the context has been cleared.
|
||||||
|
This packet can be safely ignored, its behaviour can be implicitly handled when required according to the table below.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----:| ----------- |
|
||||||
<td><code>int</code></td>
|
| `int` | Number indicating what data should be cleared. Modes are described below. |
|
||||||
<td>
|
|
||||||
Number indicating what has been cleared.
|
#### Context clear modes
|
||||||
<ul>
|
| Mode | Explanation |
|
||||||
<li><code>0</code>: The message list has been cleared.</li>
|
|:----:| ----------- |
|
||||||
<li><code>1</code>: The user list has been cleared.</li>
|
| `0` | Only the message history should be cleared. Does not normally occur. |
|
||||||
<li><code>2</code>: The channel list has been cleared.</li>
|
| `1` | Only the user list should be cleared. Does not normally occur. |
|
||||||
<li><code>3</code>: Both the message and user listing have been cleared.</li>
|
| `2` | Only the channel list should be cleared. Does not normally occur. |
|
||||||
<li><code>4</code>: The message, user and channel listing have all been cleared.</li>
|
| `3` | Clear the message history and user list. Occurs upon switching (or being switched) to another channel. |
|
||||||
</ul>
|
| `4` | Clear the message history, user list and channel list. Does not normally occur. |
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `9`: Forced disconnect
|
### Packet `9`: Forced disconnect
|
||||||
Informs the client that they have either been banned or kicked from the server.
|
Informs the client that they have either been banned or kicked from the server.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:-----------:| ----------- |
|
||||||
<td><code>bool</code></td>
|
| `bool` | If non-`0`, the next field will be defined and contain an expiration time. If `0`, the user can rejoin immediately. |
|
||||||
<td>
|
| `timestamp` | Ban expiration timestamp, present when the first field is non-`0`. |
|
||||||
<ul>
|
|
||||||
<li><code>0</code>: The client has been kicked, can reconnect immediately.</li>
|
|
||||||
<li><code>1</code>: The client has been banned, can reconnect after the timestamp (documented below) in the next param has expired.</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>timestamp</code></td>
|
|
||||||
<td>Ban expiration time, not present when the first argument is <code>0</code>.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
### Packet `10`: User update
|
### Packet `10`: User update
|
||||||
Informs that another user's details have been updated.
|
Informs that another user's details have been updated.
|
||||||
|
|
||||||
<table>
|
| Type | Description |
|
||||||
<tr>
|
|:------------:| ----------- |
|
||||||
<td><code>string</code></td>
|
| `string` | User ID of the updated user. |
|
||||||
<td>User ID of the affected user</td>
|
| `user name` | New user name of the updated user. |
|
||||||
</tr>
|
| `colour` | New user colour for the updated user. |
|
||||||
<tr>
|
| `user perms` | New permissions for the updated user. |
|
||||||
<td><code>string</code></td>
|
|
||||||
<td>New username</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>color</code></td>
|
|
||||||
<td>New username color</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><code>user permissions</code></td>
|
|
||||||
<td>User permissions</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
## Bot Messages
|
## Bot Messages
|
||||||
|
|
|
@ -7,4 +7,7 @@
|
||||||
/_/
|
/_/
|
||||||
```
|
```
|
||||||
|
|
||||||
Welcome to the repository of the temporary Flashii chat server. This is a reimplementation of the old [PHP based Sock Chat server](https://github.com/flashwave/mahou-chat/) in C#.
|
Welcome to the repository of the Flashii Chat server!
|
||||||
|
|
||||||
|
The protocol used is based on the protocol found in the original [PHP Sock Chat](https://patchii.net/sockchat/sockchat).
|
||||||
|
A rendered version of the Protocol.md document can be found on [railgun.sh/sockchat](https://railgun.sh/sockchat).
|
||||||
|
|
Loading…
Reference in a new issue