Repository navigation
message_protocol
achivaq01 edited this page Nov 27, 2023
·
1 revision
This document provides an explanation of the messages sent and received in the CrazyServer WebSocket implementation.
-
Type:
private -
From:
server - Value: Welcome message sent to clients upon connection.
-
Type:
connected -
From:
server - Id: Unique identifier for the connected client.
- Description: Notifies the server about a new client connection.
-
Type:
disconnected -
From:
server - Id: Unique identifier for the disconnected client.
- Description: Notifies the server about a client disconnection.
-
Type:
new message - Id: Unique identifier for the client sending the new message.
- Description: Notifies other connected clients about a new message.
-
Type:
new connection - Id: Unique identifier for the newly connected client.
- Description: Notifies other connected clients about a new client connection.
-
Type:
new disconnection - Id: Unique identifier for the disconnected client.
- Description: Notifies other connected clients about a client disconnection.
-
Type:
login - Success: Boolean indicating the success of the login attempt.
- Description: Sent by clients to authenticate with the server.
-
Type:
list - List: Array containing client information (id and platform).
- Description: Sent by the server to provide a list of connected clients.
-
Type:
string - Text: The text message to be displayed on the server screen.
- Description: Instructs the server to display a moving message on the screen.
-
Type:
image - Img: Base64-encoded image data.
- Description: Instructs the server to display an image on the screen.
-
Client Connection:
- Client sends a
connectedmessage. - Server responds with a
privatewelcome message and notifies other clients about the new connection.
- Client sends a
-
Client Disconnection:
- Client sends a
disconnectedmessage. - Server broadcasts the disconnection to other clients.
- Client sends a
-
Client Sends Message:
- Client sends a message with type
stringorimage. - Server processes the message and notifies other clients if needed.
- Client sends a message with type
-
Client Login:
- Client sends a
loginmessage with user credentials. - Server validates the credentials and responds with a success or failure message.
- Client sends a
-
Client Requests Client List:
- Client sends a
listmessage. - Server responds with a list of connected clients.
- Client sends a
- Messages are exchanged using JSON format.
© Team 😄