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