Comparing version 1.1.9 to 1.2.0
24
index.js
@@ -7,2 +7,3 @@ // @ts-ignore | ||
let socket = null; | ||
let isConnectedToSocket = false; | ||
// Function to connect the socket | ||
@@ -14,2 +15,3 @@ function connectSocket(url) { | ||
socket.on("connect", () => { | ||
isConnectedToSocket = true; | ||
return true; | ||
@@ -30,3 +32,2 @@ }); | ||
socket = io(url); | ||
try { | ||
@@ -58,2 +59,21 @@ socket.on("disconnect", () => { | ||
async function getCurrentPathToTrack() { | ||
if (isConnectedToSocket) { | ||
const currentPath = useCurrentPath(); | ||
if (currentPath) { | ||
const status = await socket.emit( | ||
emitEvent, | ||
`The user is in this route ${currentPath}`, | ||
() => { | ||
return "Emitted!"; | ||
} | ||
); | ||
} | ||
} | ||
} | ||
setInterval(() => { | ||
getCurrentPathToTrack(); | ||
}, 2000); | ||
module.exports = { | ||
@@ -63,3 +83,3 @@ socketConnect: connectSocket, | ||
socketEmit: emitContent, | ||
useCurrentPath: useCurrentPath, | ||
// useCurrentPath: useCurrentPath, | ||
}; |
@@ -7,3 +7,3 @@ { | ||
"name": "sockettwo", | ||
"version": "1.1.9", | ||
"version": "1.2.0", | ||
"main": "index.js", | ||
@@ -10,0 +10,0 @@ "scripts": { |
3962
127