fix url handling and websockets

This commit is contained in:
ading2210 2024-10-03 09:48:12 -04:00
parent 0cab209e9d
commit 2e6fba2c3b
8 changed files with 67 additions and 13 deletions

View file

@ -68,9 +68,6 @@ export class ReclaimTLSSocket extends EventTarget {
//set up socket callbacks
this.socket.binaryType = "arraybuffer";
this.socket.onopen = () => {
this.tls.startHandshake();
}
this.socket.onmessage = (event) => {
this.tls.handleReceivedBytes(new Uint8Array(event.data));
}
@ -82,6 +79,14 @@ export class ReclaimTLSSocket extends EventTarget {
this.status = this.CLOSED;
this.emit_event(new Event("error"));
}
if (this.socket.readyState === this.socket.CONNECTING) {
this.socket.onopen = () => {
this.tls.startHandshake();
}
}
else {
this.tls.startHandshake();
}
this.status = this.CONNECTING;
}