mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 06:10:01 -04:00
Merge branch 'master' of https://github.com/MercuryWorkshop/adrift
This commit is contained in:
commit
58c3ba546d
6 changed files with 184 additions and 48 deletions
|
@ -5,7 +5,6 @@ import {
|
|||
GetRequestHeadersCallback,
|
||||
MetaCallback,
|
||||
ReadyStateCallback,
|
||||
WebSocketFields,
|
||||
WebSocketImpl,
|
||||
} from "bare-client-custom";
|
||||
import { Connection } from "./Connection";
|
||||
|
@ -70,7 +69,7 @@ export class AdriftBareClient extends Client {
|
|||
const ws = new webSocketImpl("ws:null", protocols);
|
||||
// this will error. that's okay
|
||||
|
||||
let send = this.connection.wsconnect(
|
||||
let { send, close } = this.connection.wsconnect(
|
||||
remote,
|
||||
() => {
|
||||
onReadyState(WebSocketFields.OPEN);
|
||||
|
@ -79,8 +78,6 @@ export class AdriftBareClient extends Client {
|
|||
() => {
|
||||
onReadyState(WebSocketFields.CLOSED);
|
||||
ws.dispatchEvent(new Event("close"));
|
||||
|
||||
// what do i do for WebSocketFields.closing?
|
||||
},
|
||||
(data) => {
|
||||
ws.dispatchEvent(
|
||||
|
@ -91,11 +88,16 @@ export class AdriftBareClient extends Client {
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
(ws as any).__defineGetter__("send", () => (data: any) => {
|
||||
send(data);
|
||||
});
|
||||
(ws as any).__defineSetter__("send", () => { });
|
||||
// uv wraps it and we don't want that
|
||||
// i can probably fix later but this is fine for now -CE
|
||||
(ws as any).__defineSetter__("send", () => {});
|
||||
|
||||
(ws as any).__defineGetter__("close", (code?: number, reason?: string) => {
|
||||
close(code, reason);
|
||||
});
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue