From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/js/advancedCommunication/client.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 graphs/js/advancedCommunication/client.js (limited to 'graphs/js/advancedCommunication/client.js') diff --git a/graphs/js/advancedCommunication/client.js b/graphs/js/advancedCommunication/client.js new file mode 100644 index 0000000..7c051a8 --- /dev/null +++ b/graphs/js/advancedCommunication/client.js @@ -0,0 +1,26 @@ +const WebSocket = require("ws"); + +function addClient(userName) { + const socket = new WebSocket("ws://localhost:8080?username=" + userName); + + socket.on("open", () => { + socket.send(userName + ": trying to establish connection"); + }); + socket.on("close", (code, reason) => { + console.log( + ": Connection has been closed: [" + + code + + "] " + + reason, + ); + }); + socket.on("message", (data) => { + console.log(": " + data); + }); + return socket; +} +module.exports = { + addClient, +}; -- cgit v1.2.3