ws test
This commit is contained in:
parent
bd82c52fcd
commit
64ca53b494
@ -50,26 +50,20 @@ export class IRCWebSocketConnector
|
||||
}
|
||||
|
||||
write(format: string, ...args: any[]): void {
|
||||
this.socket?.send(formatstr(format, ...args) + '\r\n');
|
||||
this.socket?.send(formatstr(format, ...args));
|
||||
}
|
||||
|
||||
private handle() {
|
||||
let buffer: string = '';
|
||||
this.socket?.addEventListener('message', (event) => {
|
||||
const chunk = event.data.toString();
|
||||
buffer += chunk;
|
||||
const data = buffer.split('\r\n');
|
||||
buffer = data.pop() || '';
|
||||
const line = event.data.toString();
|
||||
|
||||
data.forEach((line: string) => {
|
||||
if (line.indexOf('PING') === 0 && !this.connOpts?.skipPings) {
|
||||
this.socket?.send('PONG' + line.substring(4) + '\r\n');
|
||||
this.socket?.send('PONG' + line.substring(4));
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit('data', line);
|
||||
});
|
||||
});
|
||||
|
||||
this.socket?.addEventListener('error', (err) => this.emit('error', err));
|
||||
this.socket?.addEventListener('close', (err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user