From bfd9d46892374f22f136fd8e89376dc9ea3befd4 Mon Sep 17 00:00:00 2001 From: aronmal Date: Fri, 28 Oct 2022 22:21:55 +0200 Subject: [PATCH] Add functionality to Socket.IO client --- frontend/src/components/SocketIO.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/SocketIO.tsx b/frontend/src/components/SocketIO.tsx index 3812da8..a7169c6 100644 --- a/frontend/src/components/SocketIO.tsx +++ b/frontend/src/components/SocketIO.tsx @@ -1,8 +1,27 @@ import { io } from 'socket.io-client'; function SocketIO() { - // const socket = io("wss://server-domain.com"); - const socket = io(); // The server URL will be deduced from the window.location object. + const socket = io("ws://localhost:5001"); + socket.on('test2', (warst) => { + console.log('Test2:', warst, socket.id) + }) + socket.on("connect", () => { + console.log(socket.connected); // true + setTimeout(() => { + socket.emit('test', "warst") + socket.emit('test', "tsra") + socket.emit('test', "1234") + // socket.disconnect() + }, 1000) + }); + + socket.on("test", () => { + console.log("Got test1234"); // false + }); + + socket.on("disconnect", () => { + console.log(socket.connected); // false + }); return (
SocketIO
)