From 4c4865c6f7186491ed1d5534207113486e3982b1 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Thu, 1 Jun 2023 18:49:30 +0200 Subject: [PATCH] Created the socket util --- client/src/common/utils/socket.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 client/src/common/utils/socket.js diff --git a/client/src/common/utils/socket.js b/client/src/common/utils/socket.js new file mode 100644 index 0000000..e3adb22 --- /dev/null +++ b/client/src/common/utils/socket.js @@ -0,0 +1,11 @@ +import { io } from 'socket.io-client'; + +const URL = process.env.NODE_ENV === 'production' ? "https://tools-api.gnmyt.dev/" : "http://localhost:7182"; + +export const createConnection = (type) => { + const socket = io(URL, {autoConnect: false}); + + socket.on("connect", () => socket.emit("type", type)); + + return socket; +} \ No newline at end of file