diff --git a/client/src/AdriftClient.ts b/client/src/AdriftClient.ts index f2cd4f1..962993e 100644 --- a/client/src/AdriftClient.ts +++ b/client/src/AdriftClient.ts @@ -95,87 +95,12 @@ export class AdriftBareClient extends Client { })); }); - - // const cleanup = () => { - // ws.removeEventListener('close', closeListener); - // ws.removeEventListener('message', messageListener); - // }; - - // const closeListener = () => { - // cleanup(); - // }; - - (ws as any).__defineGetter__("send", () => (data: any) => { send(data); }); (ws as any).__defineSetter__("send", () => { }); - // ws.send = (data) => { - // console.log("sending data to server:" + data); - // }; - // console.log(ws.send); - const messageListener = (event: MessageEvent) => { - // cleanup(); - - // // ws.binaryType is irrelevant when sending text - // if (typeof event.data !== 'string') - // throw new TypeError('the first websocket message was not a text frame'); - - // const message = JSON.parse(event.data) as SocketServerToClient; - - // // finally - // if (message.type !== 'open') - // throw new TypeError('message was not of open type'); - - // event.stopImmediatePropagation(); - - // onMeta({ - // protocol: message.protocol, - // setCookies: message.setCookies, - // }); - - // // now we want the client to see the websocket is open and ready to communicate with the remote - // onReadyState(WebSocketFields.OPEN); - - ws.dispatchEvent(new Event('open')); - }; - - setTimeout(messageListener, 30); - - // ws.addEventListener('close', closeListener); - ws.addEventListener('message', messageListener); - - // // CONNECTED TO THE BARE SERVER, NOT THE REMOTE - // ws.addEventListener( - // 'open', - // (event) => { - // // we have to cancel this event because it doesn't reflect the connection to the remote - // // once we are actually connected to the remote, we can dispatch a fake open event. - // event.stopImmediatePropagation(); - - // // we need to fake the readyState value again so it remains CONNECTING - // // right now, it's open because we just connected to the remote - // // but we need to fake this from the client so it thinks it's still connecting - // onReadyState(WebSocketFields.CONNECTING); - - // getRequestHeaders().then((headers) => - // WebSocketFields.prototype.send.call( - // ws, - // JSON.stringify({ - // type: 'connect', - // remote: remote.toString(), - // protocols, - // headers, - // forwardHeaders: [], - // } as SocketClientToServer) - // ) - // ); - // }, - // // only block the open event once - // { once: true } - // ); return ws;