mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 14:20:01 -04:00
WIP on websocket impl
This commit is contained in:
parent
07b0ba3a07
commit
f64cc78f9f
6 changed files with 91 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
C2SRequestType,
|
||||
C2SRequestTypes,
|
||||
C2SWSOpenPayload,
|
||||
HTTPRequestPayload,
|
||||
HTTPResponsePayload,
|
||||
S2CRequestType,
|
||||
|
@ -112,11 +113,12 @@ export class Connection {
|
|||
send: (data: any) => void;
|
||||
close: (code?: number, reason?: string) => void;
|
||||
} {
|
||||
const payload = JSON.stringify({ url });
|
||||
const payload: C2SWSOpenPayload = { url: url.toString() };
|
||||
const payloadJSON = JSON.stringify(payload);
|
||||
let seq = this.nextSeq();
|
||||
this.send(
|
||||
seq,
|
||||
new TextEncoder().encode(payload),
|
||||
new TextEncoder().encode(payloadJSON),
|
||||
C2SRequestTypes.WSOpen
|
||||
).catch((e) => {
|
||||
console.error(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue