Bridge The Gap: Chat Bridge Protocol v1 #10
Replies: 4 comments 2 replies
-
I'll keep updating the original post as we discuss the protocol and make changes to it. |
Beta Was this translation helpful? Give feedback.
-
We should also decide on the format in which we encode chat messages. It should allow for the different text formatting features in use in Minecraft and Discord. |
Beta Was this translation helpful? Give feedback.
-
Connect/Disconnect PacketsThe idea behind these packets was that information about clients and users would only need to be sent once (when they connect). The benefit of this is that chat message packets can be smaller, as they don't need to contain information like display name, display color, and other decorators (e.g. The downside is that each client will have to keep a list of all clients connected to the server, and all users connected to each client, in memory. This is not ideal, especially with Discord servers that can have hundreds or thousands of members. Should we stick with the connect/disconnect packets? Or is the hit on packet size small enough that client/user display information can be added to the chat message packets? |
Beta Was this translation helpful? Give feedback.
-
Request/Response PacketsOne of the features envisioned for this bridge was a Firstly, we could make the Discord bot parse the command, request the list of players from the Minecraft server (through request/response packets), and display that in chat. This implementation gives more freedom in how the information is displayed, each client receives the same data, but can decide to display it differently to its users. But it requires a new set of request/response packets for each command that is added. Secondly, the Discord bot could send the command to the Minecraft server, which parses it, and send a chat message with the player list to the Discord server. This implementation requires only the command packet, and the result is sent over chat. But it gives less freedom in the kind of commands that can be issued, as the result is always in the form of a chat message. Which approach should we take? |
Beta Was this translation helpful? Give feedback.
-
Setup
The chat bridge consists of several components.
There are several clients, which interface with users. Clients listen to chat messages, users joining/leaving, and other user-related events. The clients currently in use are the Khaos SMP and CMP Minecraft servers, and the Khaos Discord bot.
Lastly, there is the server, which connects all BTG clients together. It broadcasts messages dispatched by BTG clients to the other clients.
Terms
Common Data
Platform
For a client, specifies what kind of client it is.
User Selection
For users request packets, specifies which group of users is requested.
Protocol
The clients are connected to the server through a web socket connection. The handshake header must contain the protocol version that is used, as well as the auth token for the server.
Packets are sent as string-ified JSON. The structure of a packet can be seen below.
The structure for each type of payload is detailed in the next sections.
Server-bound Packets
These are packets sent by clients to the server.
1. Client Connect
This packet is sent after the connection with the server has been established.
2. Client Disconnect
This packet is sent before the client disconnects from the server.
3. User Connect
This packet is sent when a user connects to the client.
4. User Disconnect
This packet is sent when a user connects to the client.
5. Client Message
This packet is sent when a client sends a message to chat.
6. User Message
This packet is sent when a user sends a message to chat.
7. Client Whisper
This packet is sent when a client whispers to another client or user.
8. User Whisper
This packet is sent when a user whispers to another client or user.
9. Request
The client requests some data from the target client (or all clients if none is specified).
10. Response Denied
This packet is sent upon receiving a client-bound request packet, if the request is denied.
11. Response Granted
This packet is sent upon receiving a client-bound request packet, if the request is granted.
Client-bound Packets
These are packets sent by the server to clients.
1. Client Connect
This packet is broadcast after a server-bound client connect packet has been received. It contains information about the client that has connected.
2. Client Disconnect
This packet is broadcast after a server-bound client disconnect packet has been received.
3. User Connect
This packet is broadcast upon receiving a server-bound user connect packet. It contains information about the user that has connected and the client it has connected to.
4. User Disconnect
This packet is broadcast upon receiving a server-bound user disconnect packet.
5. Client Message
This packet is sent upon receiving a server-bound client message packet.
6. User Message
This packet is sent upon receiving a server-bound user message packet.
7. Client Whisper
This packet is sent upon receiving a server-bound client whisper packet.
8. User Whisper
This packet is sent upon receiving a server-bound user whisper packet.
9. Request
This packet is sent upon receiving a server-bound request packet.
10. Response Denied
This packet is sent upon receiving a server-bound response denied packet.
11. Response Granted
This packet is sent upon receiving a server-bound response granted packet.
Requests
Responses
Beta Was this translation helpful? Give feedback.
All reactions