Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();