Skip to content

Commit

Permalink
Doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
steven4547466 committed Jun 15, 2020
1 parent aa2c4ea commit 5a11e6d
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion creating_a_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ If this is successful, the server will emit a `methodResult` event with the data
memberList: []
}
```
The `memeberList` will contain all connected members. However, if this fails, usually due to a server error, you will get this data instead:
The `memeberList` will contain all connected members (in the user's connected channel). However, if this fails, usually due to a server error, you will get this data instead:
```js
{
success: false,
Expand All @@ -225,6 +225,33 @@ The `memeberList` will contain all connected members. However, if this fails, us

If it is successful, however, you should update your member list accordingly.

##### Getting the channel list

As of version 0.4.0, servers can set up channels. Getting the channel list is exactly like getting the member list, but some stuff is changed, the `method` should be `getChannelList` and it should look like:
```js
{
type: "clientRequest",
method: "getChannelList",
username: "SlickSauce",
tag: "4560",
uid: "AwesomeSauce",
id: 10704219761807360,
sessionID: "ec2b3298dc836bbebcd4"
}
```
There is no coded way this can return anything other than a `success: true` method result, but it is worth noting that servers can modify their server instances.

If everything goes well, you'll get a `methodResult` that looks like this:
```js
{
success: true,
method: "getChannelList",
type: "success",
message: "Successfully received the channel list.",
channelList: []
}
```

##### Properly reconnecting

Because of how unmodified servers work, just listening for a `reconnect` event will not be enough for the server. On any successful connect, **the server** will emit an event called `getUserData`, if your client has the data of the user (meaning the connection was actually a reconnect), your client should emit a `returnUserData` event to the server with the data returned from the login or register (that you should've saved somewhere).
Expand All @@ -237,6 +264,10 @@ socket.on("getUserData", () => {
```
If you don't do something similar, your `sessionID` will be forgotten by the server and you will always get an `invalidSessionID` error.

###### NOTICE:

**As of version 0.4.0, this only works for up to 5 minutes after disconnect (on unmodified server instances) and does not work on a server crash.** Users will **always** be reconnected to the main channel usually called General.

##### Getting the message history

On connect, if history saving is enabled, the server will emit a `method` with `type: "serverRequest"` and `method: "sendChatHistory"` to your client. The chat history will be in mapped to a key called `history` and will include up to, on a non-modified server instance, 100 messages. Newer messages always come later in the array. One message in the array would look like this:
Expand Down

0 comments on commit 5a11e6d

Please sign in to comment.