How to use the uws.CLOSED function in uws

To help you get started, we’ve selected a few uws 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 AnotherGenZ / ManyMelodies / src / VoiceConnection.js View on Github external
connect(data) {
        if (this.connecting) {
            return;
        }
        this.connecting = true;
        if (this.ws && this.ws.readyState !== WebSocket.CLOSED) {
            this.disconnect(undefined, true);
            return setTimeout(() => this.connect(data), 500);
        }
        if (!data.endpoint || !data.token || !data.session_id || !data.user_id) {
            this.disconnect(new Error('Malformed voice server update: ' + JSON.stringify(data)));
            return;
        }
        this.channelID = data.channel_id;
        this.endpoint = data.endpoint.split(':')[0];
        this.ws = new WebSocket('wss://' + this.endpoint);
        let connectionTimeout = setTimeout(() => {
            if (this.connecting) {
                this.disconnect(new Error('Voice connection timeout'));
            }
            connectionTimeout = null;
        }, this.shard.client ? this.shard.client.options.connectionTimeout : 30000);

uws

## Go to [https://github.com/uNetworking/uWebSockets.js](https://github.com/uNetworking/uWebSockets.js).

Apache-2.0
Latest version published 4 years ago

Package Health Score

63 / 100
Full package analysis