added proper connection check

This commit is contained in:
2026-04-08 15:09:08 -05:00
parent fd625a7420
commit 00eeff1282
2 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -25,7 +25,7 @@ export class TetherClient {
};
disconnect = () => {
if (!this.ws) {
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
throw new Error('Not connected to Tether');
}
this.ws.close();
@@ -34,7 +34,7 @@ export class TetherClient {
subscribe = (query: string, callback: (data: any) => void) => {
this.subscribedQueries.set(query, callback);
if (!this.ws) {
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
throw new Error('Not connected to Tether');
}
this.ws.send(JSON.stringify({
@@ -45,7 +45,7 @@ export class TetherClient {
unsubscribe = (query: string) => {
this.subscribedQueries.delete(query);
if (!this.ws) {
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
throw new Error('Not connected to Tether');
}
this.ws.send(JSON.stringify({
@@ -55,7 +55,7 @@ export class TetherClient {
};
sendMutation = (mutationName: string, params: any) => {
if (!this.ws) {
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
throw new Error('Not connected to Tether');
}
this.ws.send(JSON.stringify({