Skip to content

Commit

Permalink
chore: update socket
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Nov 17, 2024
1 parent 045249a commit cc2a796
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions modules/hook/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const useWebSocket = (url: string, room: string, user: string) => {

function ping(data: any) {
const i = setInterval(() => {
if (countRef.current > 0) {
if (
countRef.current > 3
) {
setIsConnected(true);
return clearInterval(i);
}
Expand All @@ -25,7 +27,7 @@ const useWebSocket = (url: string, room: string, user: string) => {
);
countRef.current++;
}
}, 1000);
}, 100);

console.log(`WebSocket connection established: ${room}`);
}
Expand Down
6 changes: 5 additions & 1 deletion utils/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ if (args === "deploy") {
"https://api.deno.com/databases/8ce5f998-0c99-465e-971b-b8911d896fed/connect",
);

getAll(kd);
const iter = kd.list({ prefix: [] });
await Array.fromAsync(iter, ({ key, value }) => {
console.log(`[${key}]:`, value);
return value;
});
} else {
getAll(kv);
}
Expand Down

0 comments on commit cc2a796

Please sign in to comment.