dev ws trolling

This commit is contained in:
Spencer Pogorzelski 2023-08-11 16:30:30 -07:00
parent d307d9cd94
commit 539e0fdc6e
5 changed files with 270 additions and 44 deletions

27
client/DevWsTransport.ts Normal file
View file

@ -0,0 +1,27 @@
import Transport from "./Transport";
export class DevWsTransport extends Transport {
ws: WebSocket;
constructor(onopen, onclose) {
super(onopen, onclose);
this.ws = new WebSocket("ws://localhost:3000/dev-ws");
this.ws.binaryType = "arraybuffer";
this.ws.onopen = onopen;
this.ws.onclose = onclose;
this.ws.onmessage = this.onmessage.bind(this);
}
onmessage(msg: MessageEvent<any>) {
if (msg.data instanceof ArrayBuffer) {
this.ondata(msg.data);
return;
}
// ignore text messages
}
send(data: ArrayBuffer) {
this.ws.send(data);
}
}