imp(wetsock) plugin handling and implementation

This commit is contained in:
gh0sTedBuddy
2024-04-07 20:07:50 +01:00
parent 2c72652e15
commit 2a2a8c800f
4 changed files with 269 additions and 23 deletions

View File

@@ -0,0 +1,27 @@
/**
* Represents a connected WebSocket client
*/
export default class SocketClient {
#id;
#ws;
/**
* Create a new websocket server client instance.
* @param {string} id - The unique identifier of the client.
* @param {ServerWebSocket} - The Socket object for sending messages.
*/
constructor(id, ws) {
this.#id = id;
this.#ws = ws;
}
/**
* Sends a message to the client
* @param {*} message - The data to be sent to the client. Will be converted to string if not a string.
*/
send(message) {
if(typeof(message) != 'string') message = JSON.stringify(message);
this.#ws.send(message);
}
}