change APISocket to allow country code and channelId definition
This commit is contained in:
parent
50e3a95161
commit
d952050f42
7
API.md
7
API.md
|
@ -17,7 +17,9 @@ All requests are made as JSON encoded array.
|
||||||
|
|
||||||
All chat messages, except the once you send with `chat` or `mcchat`, will be sent to you in the form:
|
All chat messages, except the once you send with `chat` or `mcchat`, will be sent to you in the form:
|
||||||
|
|
||||||
```["msg", name, message]```
|
```["msg", name, message, country, channelId]```
|
||||||
|
channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come.
|
||||||
|
country is the [two-letter country code](https://www.nationsonline.org/oneworld/country_code_list.htm) in lowercase
|
||||||
### Subscribe to online user counter
|
### Subscribe to online user counter
|
||||||
```["sub", "online"]```
|
```["sub", "online"]```
|
||||||
|
|
||||||
|
@ -61,8 +63,9 @@ wait Seconds is the cooldown like in `retpixel` above.
|
||||||
|
|
||||||
(got an extra command because minecraftname gets resolved to linked pixelplanet user if possible)
|
(got an extra command because minecraftname gets resolved to linked pixelplanet user if possible)
|
||||||
### Send Chat Message
|
### Send Chat Message
|
||||||
```["chat", name, message]```
|
```["chat", name, message, country, channelId]```
|
||||||
|
|
||||||
|
channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come.
|
||||||
(messages with the name "info" will be displayed as red notifications in the chat window)
|
(messages with the name "info" will be displayed as red notifications in the chat window)
|
||||||
### Link Minecraft Account to pixelplanet Account
|
### Link Minecraft Account to pixelplanet Account
|
||||||
```["linkacc", minecraftid, minecraftname, pixelplanetname]```
|
```["linkacc", minecraftid, minecraftname, pixelplanetname]```
|
||||||
|
|
|
@ -90,9 +90,9 @@ class APISocketServer extends WebSocketEvents {
|
||||||
sendapi,
|
sendapi,
|
||||||
ws = null,
|
ws = null,
|
||||||
) {
|
) {
|
||||||
if (!sendapi || channelId !== 0) return;
|
if (!sendapi) return;
|
||||||
|
|
||||||
const sendmsg = JSON.stringify(['msg', name, msg]);
|
const sendmsg = JSON.stringify(['msg', name, msg, country, channelId]);
|
||||||
this.wss.clients.forEach((client) => {
|
this.wss.clients.forEach((client) => {
|
||||||
if (client !== ws
|
if (client !== ws
|
||||||
&& client.subChat
|
&& client.subChat
|
||||||
|
@ -250,9 +250,9 @@ class APISocketServer extends WebSocketEvents {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (command == 'chat') {
|
if (command == 'chat') {
|
||||||
const [name, msg] = packet;
|
const [name, msg, country, channelId] = packet;
|
||||||
chatProvider.broadcastChatMessage(name, msg, 'xx', 0, false);
|
chatProvider.broadcastChatMessage(name, msg, country, channelId, false);
|
||||||
this.broadcastChatMessage(name, msg, 'xx', 0, true, ws);
|
this.broadcastChatMessage(name, msg, country, channelId, true, ws);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (command == 'linkacc') {
|
if (command == 'linkacc') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user