mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 06:10:01 -04:00
clean unneeded stuff
This commit is contained in:
parent
f6ad470a69
commit
085477caf4
1 changed files with 0 additions and 75 deletions
|
@ -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) => {
|
(ws as any).__defineGetter__("send", () => (data: any) => {
|
||||||
send(data);
|
send(data);
|
||||||
});
|
});
|
||||||
(ws as any).__defineSetter__("send", () => { });
|
(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;
|
return ws;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue