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",
|
"name": "usetether",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"author": "Braydon (Rainnny) <braydonrainnny@gmail.com>",
|
"author": "Braydon (Rainnny) <braydonrainnny@gmail.com>",
|
||||||
"description": "An API designed to provide real-time access to a user's Discord data.",
|
"description": "An API designed to provide real-time access to a user's Discord data.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -29,13 +29,11 @@
|
|||||||
"@types/bun": "latest",
|
"@types/bun": "latest",
|
||||||
"@types/react": "^18.3.5",
|
"@types/react": "^18.3.5",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1"
|
||||||
"react-dom": "18.3.1"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0",
|
|
||||||
"react": "*",
|
"react": "*",
|
||||||
"react-dom": "*"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tsup": "^8.2.4"
|
"tsup": "^8.2.4"
|
||||||
|
@ -10,9 +10,9 @@ export const useTetherWS = (
|
|||||||
secure: true,
|
secure: true,
|
||||||
}
|
}
|
||||||
): DiscordUser | undefined => {
|
): DiscordUser | undefined => {
|
||||||
|
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
|
||||||
const [user] = useState<DiscordUser | undefined>();
|
const [user] = useState<DiscordUser | undefined>();
|
||||||
|
|
||||||
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Prevent from running on the server
|
// Prevent from running on the server
|
||||||
if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
@ -27,12 +27,13 @@ export const useTetherWS = (
|
|||||||
console.log("[Tether] Connecting to the WebSocket server...");
|
console.log("[Tether] Connecting to the WebSocket server...");
|
||||||
socket = new WebSocket(url); // Connect to the gateway
|
socket = new WebSocket(url); // Connect to the gateway
|
||||||
socket.addEventListener("open", () => {
|
socket.addEventListener("open", () => {
|
||||||
|
socket.send(JSON.stringify({ op: 0, snowflake: snowflake })); // Track the user
|
||||||
console.log(
|
console.log(
|
||||||
"[Tether] WebSocket connection established!",
|
"[Tether] WebSocket connection established!",
|
||||||
snowflake
|
snowflake
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
socket.addEventListener("close", connect);
|
socket.addEventListener("close", connect); // Reconnect on close
|
||||||
|
|
||||||
socket.addEventListener("message", (event) => {
|
socket.addEventListener("message", (event) => {
|
||||||
console.log("data:", event.data);
|
console.log("data:", event.data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user