How to use the isomorphic-ws.CLOSING function in isomorphic-ws

To help you get started, we’ve selected a few isomorphic-ws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iov-one / iov-core / packages / iov-socket / src / socketwrapper.ts View on Github external
break;
      case WebSocket.CLOSED:
        // nothing to be done
        break;
      case WebSocket.CONNECTING:
        // imitate missing abort API
        this.socket.onopen = () => 0;
        this.socket.onclose = () => 0;
        this.socket.onerror = () => 0;
        this.socket.onmessage = () => 0;
        this.socket = undefined;
        if (this.closeHandler) {
          this.closeHandler({ wasClean: false, code: 4001 });
        }
        break;
      case WebSocket.CLOSING:
        // already closing. Let it proceed
        break;
      default:
        throw new Error(`Unknown readyState: ${this.socket.readyState}`);
    }
  }
github cube-js / cube.js / packages / cubejs-client-ws-transport / src / index.js View on Github external
ws.onclose = () => {
        if (ws && ws.readyState !== WebSocket.CLOSED && ws.readyState !== WebSocket.CLOSING) {
          ws.close();
        }
        if (ws.reconcileTimer) {
          clearInterval(ws.reconcileTimer);
          ws.reconcileTimer = null;
        }
        if (this.ws === ws) {
          this.ws = null;
          if (Object.keys(this.messageIdToSubscription).length) {
            this.initSocket();
          }
        }
      };

isomorphic-ws

Isomorphic implementation of WebSocket

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis