track the user when the WS is connected
All checks were successful
Publish JS SDK / docker (push) Successful in 14s
All checks were successful
Publish JS SDK / docker (push) Successful in 14s
This commit is contained in:
parent
1d34348daf
commit
0da130995c
BIN
JS-SDK/bun.lockb
BIN
JS-SDK/bun.lockb
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "usetether",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"author": "Braydon (Rainnny) <braydonrainnny@gmail.com>",
|
||||
"description": "An API designed to provide real-time access to a user's Discord data.",
|
||||
"keywords": [
|
||||
@ -29,13 +29,11 @@
|
||||
"@types/bun": "latest",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-dom": "*"
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tsup": "^8.2.4"
|
||||
|
@ -10,9 +10,9 @@ export const useTetherWS = (
|
||||
secure: true,
|
||||
}
|
||||
): DiscordUser | undefined => {
|
||||
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
|
||||
const [user] = useState<DiscordUser | undefined>();
|
||||
|
||||
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
|
||||
useEffect(() => {
|
||||
// Prevent from running on the server
|
||||
if (typeof window === "undefined") {
|
||||
@ -27,12 +27,13 @@ export const useTetherWS = (
|
||||
console.log("[Tether] Connecting to the WebSocket server...");
|
||||
socket = new WebSocket(url); // Connect to the gateway
|
||||
socket.addEventListener("open", () => {
|
||||
socket.send(JSON.stringify({ op: 0, snowflake: snowflake })); // Track the user
|
||||
console.log(
|
||||
"[Tether] WebSocket connection established!",
|
||||
snowflake
|
||||
);
|
||||
});
|
||||
socket.addEventListener("close", connect);
|
||||
socket.addEventListener("close", connect); // Reconnect on close
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
console.log("data:", event.data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user