mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-17 15:50:01 -04:00
dev ws trolling
This commit is contained in:
parent
d307d9cd94
commit
539e0fdc6e
5 changed files with 270 additions and 44 deletions
27
client/DevWsTransport.ts
Normal file
27
client/DevWsTransport.ts
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue