mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 14:20:01 -04:00
impl C2S ws close
This commit is contained in:
parent
321bbf9734
commit
8babd1896e
3 changed files with 14 additions and 6 deletions
|
@ -175,7 +175,6 @@ export class Connection {
|
|||
|
||||
return {
|
||||
send: (data) => {
|
||||
console.log("Reached Connection.ts send!");
|
||||
if (!this.openSockets[seq]) {
|
||||
throw new Error("send on closed socket");
|
||||
}
|
||||
|
@ -210,7 +209,8 @@ export class Connection {
|
|||
throw new Error("Unexpected type passed to send");
|
||||
},
|
||||
close: (code?: number, reason?: string) => {
|
||||
const payload = JSON.stringify({ code, reason });
|
||||
const payload = { code, reason };
|
||||
const payloadJSON = JSON.stringify(payload);
|
||||
this.send(
|
||||
seq,
|
||||
new TextEncoder().encode(payload),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue