This commit is contained in:
parent
ce31226448
commit
455d83543b
@ -11,37 +11,9 @@ export const useTetherWS = (
|
||||
): Snowflake => {
|
||||
const [user] = useState<Snowflake>(snowflake);
|
||||
|
||||
const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
|
||||
useEffect(() => {
|
||||
// Prevent from running on the server
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
let socket: WebSocket; // The current WebSocket connection
|
||||
|
||||
/**
|
||||
* Establish a connection with the API.
|
||||
*/
|
||||
function connect() {
|
||||
console.log("connecting to:", url);
|
||||
socket = new WebSocket("wss://usetether.rest/gateway"); // Connect to the gateway
|
||||
socket.addEventListener("open", () =>
|
||||
console.log("[Tether] WebSocket connection established!")
|
||||
);
|
||||
// socket.addEventListener("close", connect);
|
||||
//
|
||||
// socket.addEventListener("message", (event) => {
|
||||
// console.log("data:", event.data);
|
||||
// });
|
||||
}
|
||||
connect();
|
||||
|
||||
// Cleanup
|
||||
return () => {
|
||||
// socket.removeEventListener("close", connect);
|
||||
socket.close();
|
||||
};
|
||||
}, [url]);
|
||||
console.log("HELLO WORLD");
|
||||
}, [snowflake]);
|
||||
|
||||
return user;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user