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