Add Networking protocol
86
Networking-protocol.md
Normal file
86
Networking-protocol.md
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
# Types
|
||||||
|
|
||||||
|
### ServerResponse
|
||||||
|
|
||||||
|
| Name | Value | Description |
|
||||||
|
| -------------- | ----- | -------------------------------------------------------------------- |
|
||||||
|
| AuthSuccess | 0 | The chatter is successfully authenticated |
|
||||||
|
| AuthError | 1 | The chatter want to connect with a name already used |
|
||||||
|
| RoomCreated | 2 | The room has been created |
|
||||||
|
| RoomNotCreated | 3 | A room with the same name already exists |
|
||||||
|
| RoomJoined | 4 | The chatter joined the room |
|
||||||
|
| RoomNotJoined | 5 | The name of the room does not exist |
|
||||||
|
| NotInRoom | 6 | The chatter must be in a room to send a chat message or leave a room |
|
||||||
|
|
||||||
|
# Packets
|
||||||
|
|
||||||
|
## Client -> Server
|
||||||
|
|
||||||
|
### LoginPacket
|
||||||
|
|
||||||
|
The client first send this packet to indicate his name
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------ | ------ | ----------------------------------------- |
|
||||||
|
| Pseudo | String | The name of the chatter who wants to join |
|
||||||
|
|
||||||
|
### RequestRoomListPacket
|
||||||
|
|
||||||
|
The client sends this packet when needing to update the list of rooms available.
|
||||||
|
|
||||||
|
This packet has no body.
|
||||||
|
|
||||||
|
### RoomListPacket
|
||||||
|
|
||||||
|
Sends the list of rooms available.
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| --------- | ------------------ | ---------------------- |
|
||||||
|
| RoomNames | ArrayList\<String> | the list of room names |
|
||||||
|
### CreateRoomPacket
|
||||||
|
|
||||||
|
Create a room by name. The server responds with a ResponsePacket.
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| -------- | ------ | ------------------------------ |
|
||||||
|
| RoomName | String | The name of the room to create |
|
||||||
|
### JoinRoomPacket
|
||||||
|
|
||||||
|
Join a room by name.
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| -------- | ------ | ------------------------------ |
|
||||||
|
| RoomName | String | The name of the room to create |
|
||||||
|
### SendChatMessagePacket
|
||||||
|
|
||||||
|
Send a chat message
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------- | ------ | ------------------------ |
|
||||||
|
| Content | String | The chat message to send |
|
||||||
|
|
||||||
|
### LeaveRoomPacket
|
||||||
|
|
||||||
|
Leave a room.
|
||||||
|
|
||||||
|
This packet has no body
|
||||||
|
|
||||||
|
## Server -> Client
|
||||||
|
|
||||||
|
### ChatMessagePacket
|
||||||
|
|
||||||
|
Broadcast the chat message
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------- | ------- | ---------------------------- |
|
||||||
|
| Time | Instant | The timestamp of the message |
|
||||||
|
| Chatter | String | The emitter of the message |
|
||||||
|
| Content | String | The chat message to send |
|
||||||
|
### ResponsePacket
|
||||||
|
|
||||||
|
The server responds to the client when trying to perform operations such as authenticating, joining rooms, creating rooms
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| -------- | ---- | ----------------------------------------- |
|
||||||
|
| Response | Int | a ServerResponse depending on the request |
|
||||||
Reference in New Issue
Block a user