Created the socket util
This commit is contained in:
parent
23d43e4af5
commit
4c4865c6f7
11
client/src/common/utils/socket.js
Normal file
11
client/src/common/utils/socket.js
Normal file
@ -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;
|
||||||
|
}
|
Reference in New Issue
Block a user