How to use the stanza-shims.WebSocket function in stanza-shims

To help you get started, we’ve selected a few stanza-shims 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 legastero / stanza / src / transports / websocket.ts View on Github external
return this.disconnect();
                }
            }
            this.client.emit('stream:data', stanzaObj, name);
        });

        this.parser.on('error', (err: any) => {
            const streamError = {
                condition: StreamErrorCondition.InvalidXML
            };
            this.client.emit('stream:error', streamError, err);
            this.send(this.stanzas.export('error', streamError)!.toString());
            return this.disconnect();
        });

        this.conn = new WebSocket(opts.url, 'xmpp');
        this.conn.onerror = (e: any) => {
            if (e.preventDefault) {
                e.preventDefault();
            }
            console.error(e);
        };
        this.conn.onclose = (e: any) => {
            this.client.emit('disconnected', e);
        };
        this.conn.onopen = () => {
            this.sm.started = false;
            this.client.emit('connected');
            this.send(this.startHeader());
        };
        this.conn.onmessage = wsMsg => {
            const data = Buffer.from(wsMsg.data as string, 'utf8').toString();

stanza-shims

Runtime shims used by StanzaJS for node, browsers, and React Native

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis