Merge pull request 'documentation-updates' (#1) from documentation-updates into mistress
Reviewed-on: https://patchii.net///flashii/sharp-chat/pulls/1
This commit is contained in:
commit
7d3cf5de62
3 changed files with 215 additions and 499 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
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`
|
||||
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`
|
||||
Any number ranging from `-9007199254740991` to `9007199254740991`, `Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER` in JavaScript.
|
||||
|
||||
|
||||
### `string`
|
||||
Any printable unicode character, except `\t` which is used to separate packets.
|
||||
|
||||
|
||||
### `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`
|
||||
A `string` containing only alphanumeric characters (any case), `-` or `_`.
|
||||
|
||||
|
||||
### `color`
|
||||
Any valid value for the CSS `color` property.
|
||||
### `colour`
|
||||
Any valid value for the CSS `colour` property.
|
||||
Further documentation can be found [on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
|
||||
|
||||
|
||||
### `message flags`
|
||||
Message flags alter how a message should be displayed to the client, these are all `bool` values.
|
||||
The parts are as follows:
|
||||
|
||||
- Username should appear using a **bold** 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.
|
||||
- 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.
|
||||
|
||||
|
||||
### `user permissions`
|
||||
User permissions are a set of flags separated by either the form feed character (`\f` / `0x0C`) or a space (<code> </code> / `0x20`).
|
||||
### `user perms`
|
||||
User permissions are a set of flags separated by either the form feed character (`\f` / `0x0C`) or a space (' ' / `0x20`).
|
||||
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.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<td>Rank of the user. Used to determine what channels a user can access or what other users the user can moderate.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>bool</code></td>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:------:| ----------- |
|
||||
| `int` | Rank of the user. Used to determine what channels a user can access or what other users the user can moderate. |
|
||||
| `bool` | Indicates whether the user the ability kick/ban/unban others. |
|
||||
| `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. |
|
||||
| `bool` | Indicates whether the user can set an alternate display name. |
|
||||
| `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. |
|
||||
|
||||
|
||||
|
||||
## Client Packets
|
||||
|
@ -82,23 +69,35 @@ These are the packets sent from the client to the server.
|
|||
### Packet `0`: Ping
|
||||
Used to prevent the client from closing the session due to inactivity.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>User ID</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:--------:| ----------- |
|
||||
| `string` | User ID of the current user. |
|
||||
|
||||
|
||||
### Packet `1`: Authentication
|
||||
Takes a variable number of parameters that are fed into the authentication script associated with the chat.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>...string</code></td>
|
||||
<td>Any amount of data required to complete authentication</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:-----------:| ----------- |
|
||||
| `...string` | Any amount of data required to complete authentication. |
|
||||
|
||||
#### Original Sock Chat phpBB format
|
||||
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
|
||||
|
@ -106,16 +105,10 @@ Informs the server that the user has sent a message.
|
|||
|
||||
Commands are described lower in the document.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>User ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>Message text, may not contain <code>\t</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:--------:| ----------- |
|
||||
| `string` | User ID of the current user. |
|
||||
| `string` | Message text, cannot contain a tab character `\t`. |
|
||||
|
||||
|
||||
## Server Packets
|
||||
|
@ -124,12 +117,9 @@ These are the packets sent from the server to the client.
|
|||
### Packet `0`: Pong
|
||||
Response to client packet `0`: Ping.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:--------:| ----------- |
|
||||
| `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. |
|
||||
|
||||
|
||||
### Packet `1`: Join/Auth
|
||||
|
@ -138,532 +128,255 @@ While authenticated this packet indicates that a new user has joined the server/
|
|||
#### Successful authentication response
|
||||
Informs the client that authentication has succeeded.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td><code>y</code></td>
|
||||
</tr>
|
||||
<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>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>
|
||||
|
||||
| Type | Description |
|
||||
|:--------------:| ----------- |
|
||||
| `string` | `y` to indicate a successful authentication attempt. |
|
||||
| `string` | User ID of the authenticated user. |
|
||||
| `user name` | User name of the authenticated user. |
|
||||
| `colour` | User colour of the authenticated user. |
|
||||
| `user perms` | Permissions for the authenticated user. |
|
||||
| `channel name` | Default channel the user will join following this packet. |
|
||||
| `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. |
|
||||
|
||||
#### Failed authentication response
|
||||
Informs the client that authentication has failed.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td><code>n</code></td>
|
||||
</tr>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:-----------:| ----------- |
|
||||
| `string` | `n` to indicate a failed authentication attempt. |
|
||||
| `string` | A reason string indicating the reason why the authentication attempt failed, options are listed below. |
|
||||
| `timestamp` | If included, indicates a ban expiration timestamp. Usually paired with the `joinfail` reason string. |
|
||||
|
||||
##### 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
|
||||
Informs the client that a user has joined.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>timestamp</code></td>
|
||||
<td>Time the user joined</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>User ID</td>
|
||||
</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>
|
||||
| Type | Description |
|
||||
|:------------:| ----------- |
|
||||
| `timestamp` | Timestamp at which the user joined. |
|
||||
| `string` | User ID of the joining user. |
|
||||
| `user name` | User name of the joining user. |
|
||||
| `colour` | User colour for the joining user. |
|
||||
| `user perms` | Permissions for the joining user. |
|
||||
| `string` | Message ID associated with this event. |
|
||||
|
||||
|
||||
### Packet `2`: Chat message
|
||||
Informs the client that a chat message has been received.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>timestamp</code></td>
|
||||
<td>Time when the message was received by the server</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>
|
||||
User ID.
|
||||
If <code>-1</code> this message is an informational message from the server and the next field takes on a special form.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>
|
||||
<p>Message, sanitised by the server</p>
|
||||
<p>
|
||||
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>
|
||||
| Type | Description |
|
||||
|:---------------:| ----------- |
|
||||
| `timestamp` | Timestamp at which the message was received by the server. |
|
||||
| `string` | User ID of the author. If `-1` the message body will contain a formatted informational message documented below. |
|
||||
| `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. |
|
||||
| `string` | Message ID. |
|
||||
| `message flags` | Message flags. |
|
||||
|
||||
#### Informational message formatting
|
||||
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`.
|
||||
Bot message formats are described lower in the document.
|
||||
|
||||
| Type | Description |
|
||||
|:-----------:| ----------- |
|
||||
| `bool` | If `1`, this message should be displayed as an error message. If `0`, it should be displayed as a normal informational message. |
|
||||
| `string` | Informational message format name. List of formats is described below. |
|
||||
| `...string` | Any number of parameters required by the format string. |
|
||||
|
||||
|
||||
### Packet `3`: User disconnect
|
||||
Informs the client that a user has disconnected.
|
||||
|
||||
<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>string</code></td>
|
||||
<td>
|
||||
One of four disconnect reasons.
|
||||
<ul>
|
||||
<li><code>leave</code>: The user gracefully left, e.g. "x logged out".</li>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:-----------:| ----------- |
|
||||
| `string` | User ID of the disconnecting user. |
|
||||
| `user name` | User name of the disconnecting user. |
|
||||
| `string` | Reason for disconnecting, described below. |
|
||||
| `timestamp` | Timestamp when the user disconnected. |
|
||||
| `string` | Message ID associated with this event. |
|
||||
|
||||
#### Disconnect reasons
|
||||
| Reason | Explanation |
|
||||
| --------- | ----------- |
|
||||
| `leave` | User gracefully left, e.g. "xyz logged out". |
|
||||
| `kick` | User got banned, kicked or otherwise unvoluntarily had their session terminated, e.g. "xyz has been kicked". |
|
||||
| `flood` | User got kicked for exceeding the flood protection limit, e.g. "xyz has been kicked for spam". |
|
||||
| `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. |
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
<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>
|
||||
This packet informs the user about channel related updates.
|
||||
The only consistent parameter across sub-packets is the first one described as follows.
|
||||
|
||||
| Type | Description |
|
||||
|:-----:| -------------- |
|
||||
| `int` | Sub-packet ID. |
|
||||
|
||||
#### Sub-packet `0`: Channel creation
|
||||
Informs the client that a channel has been created.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>channel name</code></td>
|
||||
<td>The name of the new 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>
|
||||
|
||||
| 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. |
|
||||
|
||||
#### Sub-packet `1`: Channel update
|
||||
Informs the client that details of a channel has changed.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>channel name</code></td>
|
||||
<td>Old/current name of the channel</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
|
||||
| Type | Description |
|
||||
|:--------------:| ----------- |
|
||||
| `channel name` | Previous name of the channel. |
|
||||
| `channel name` | New name of the 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. |
|
||||
|
||||
#### Sub-packet `2`: Channel deletion
|
||||
Informs the client that a channel has been deleted
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>channel name</code></td>
|
||||
<td>Name of the channel that has been deleted</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:--------------:| ----------- |
|
||||
| `channel name` | Name of the channel to be deleted. |
|
||||
|
||||
|
||||
### Packet `5`: Channel switching
|
||||
This packet informs the client about channel switching.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<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>
|
||||
|
||||
| Type | Description |
|
||||
|:-----:| -------------- |
|
||||
| `int` | Sub-packet ID. |
|
||||
|
||||
#### Sub-packet `0`: Channel join
|
||||
Informs the client that a user has joined the channel.
|
||||
|
||||
<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>string</code></td>
|
||||
<td>Message ID</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
| Type | Description |
|
||||
|:------------:| ----------- |
|
||||
| `string` | User ID of the user joining the channel. |
|
||||
| `user name` | User name of the user joining the channel. |
|
||||
| `colour` | User colour of the user joining the channel. |
|
||||
| `user perms` | Permissions of the user joining the channel. |
|
||||
| `string` | Message ID associated with this event. |
|
||||
|
||||
#### Sub-packet `1`: Channel departure
|
||||
Informs the client that a user has left the channel.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>User ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>Message ID</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
| Type | Description |
|
||||
|:------------:| ----------- |
|
||||
| `string` | User ID of the user leaving the channel. |
|
||||
| `string` | Message ID associated with this event. |
|
||||
|
||||
#### Sub-packet `2`: Forced channel switch
|
||||
Informs the client that it has been forcibly switched to a different channel.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>channel name</code></td>
|
||||
<td>The name of the channel that the user has been switched to</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:--------------:| ----------- |
|
||||
| `channel name` | Name of the channel the current user is now present in. |
|
||||
|
||||
|
||||
### Packet `6`: Message deletion
|
||||
Informs the client that a message has been deleted.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>Message ID of the deleted message</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:--------:| ----------- |
|
||||
| `string` | Message ID of the message to be deleted. |
|
||||
|
||||
|
||||
### Packet `7`: Context information
|
||||
Informs the client about the context of a channel before the client was present.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:-----:| -------------- |
|
||||
| `int` | Sub-packet ID. |
|
||||
|
||||
#### Sub-packet `0`: Existing users
|
||||
Informs the client about users already present in the channel.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<td>Amount of users present in the channel</td>
|
||||
</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>
|
||||
| Type | Description |
|
||||
|:-----:| ----------- |
|
||||
| `int` | Amount of users present in the current channel. |
|
||||
| | A repetition of a number of fields based on the number above, described below. |
|
||||
|
||||
##### 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
|
||||
Informs the client about an existing message in a channel.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>timestamp</code></td>
|
||||
<td>Time when the message was received by the server</td>
|
||||
</tr>
|
||||
<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>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>
|
||||
|
||||
| Type | Description |
|
||||
|:---------------:| ----------- |
|
||||
| `timestamp` | Timestamp at which the message was received by the server. |
|
||||
| `string` | User ID of the author. If `-1` the message body will contain a formatted informational message documented below. |
|
||||
| `user name` | User name of the author of this message. |
|
||||
| `colour` | User colour of the author of this message. |
|
||||
| `user perms` | Permissions of the author of this message. |
|
||||
| `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. |
|
||||
| `string` | Message ID. |
|
||||
| `bool` | If non-`0` this message should trigger notifications (sounds, banners, etc) on the client. |
|
||||
| `message flags` | Message flags. |
|
||||
|
||||
#### Sub-packet `2`: Channels
|
||||
Informs the client about the channels on the server.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<td>Amount of channels on the channel</td>
|
||||
</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>
|
||||
| Type | Description |
|
||||
|:-----:| ----------- |
|
||||
| `int` | Amount of channels on the server. |
|
||||
| | A repetition of a number of fields based on the number above, described below. |
|
||||
|
||||
##### 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
|
||||
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>
|
||||
<tr>
|
||||
<td><code>int</code></td>
|
||||
<td>
|
||||
Number indicating what has been cleared.
|
||||
<ul>
|
||||
<li><code>0</code>: The message list has been cleared.</li>
|
||||
<li><code>1</code>: The user list has been cleared.</li>
|
||||
<li><code>2</code>: The channel list has been cleared.</li>
|
||||
<li><code>3</code>: Both the message and user listing have been cleared.</li>
|
||||
<li><code>4</code>: The message, user and channel listing have all been cleared.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
| Type | Description |
|
||||
|:-----:| ----------- |
|
||||
| `int` | Number indicating what data should be cleared. Modes are described below. |
|
||||
|
||||
#### Context clear modes
|
||||
| Mode | Explanation |
|
||||
|:----:| ----------- |
|
||||
| `0` | Only the message history should be cleared. Does not normally occur. |
|
||||
| `1` | Only the user list should be cleared. Does not normally occur. |
|
||||
| `2` | Only the channel list should be cleared. Does not normally occur. |
|
||||
| `3` | Clear the message history and user list. Occurs upon switching (or being switched) to another channel. |
|
||||
| `4` | Clear the message history, user list and channel list. Does not normally occur. |
|
||||
|
||||
|
||||
### Packet `9`: Forced disconnect
|
||||
Informs the client that they have either been banned or kicked from the server.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>bool</code></td>
|
||||
<td>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:-----------:| ----------- |
|
||||
| `bool` | If non-`0`, the next field will be defined and contain an expiration time. If `0`, the user can rejoin immediately. |
|
||||
| `timestamp` | Ban expiration timestamp, present when the first field is non-`0`. |
|
||||
|
||||
|
||||
### Packet `10`: User update
|
||||
Informs that another user's details have been updated.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><code>string</code></td>
|
||||
<td>User ID of the affected user</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
| Type | Description |
|
||||
|:------------:| ----------- |
|
||||
| `string` | User ID of the updated user. |
|
||||
| `user name` | New user name of the updated user. |
|
||||
| `colour` | New user colour for the updated user. |
|
||||
| `user perms` | New permissions for the updated user. |
|
||||
|
||||
|
||||
## 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