From 02f698f8a91006af6e4e6193fc2062601bb17333 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 1 Jul 2023 20:18:10 -0400 Subject: [PATCH] Update networking --- src/core/communication/SocketConnection.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/communication/SocketConnection.ts b/src/core/communication/SocketConnection.ts index 4d493f70..e7d70324 100644 --- a/src/core/communication/SocketConnection.ts +++ b/src/core/communication/SocketConnection.ts @@ -87,6 +87,7 @@ export class SocketConnection extends EventDispatcher implements IConnection this._dataBuffer = new ArrayBuffer(0); this._socket = new WebSocket(socketUrl); + this._socket.binaryType = 'arraybuffer'; this._socket.addEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen); this._socket.addEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose); @@ -129,16 +130,9 @@ export class SocketConnection extends EventDispatcher implements IConnection //this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event); - const reader = new FileReader(); + this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, event.data); - reader.readAsArrayBuffer(event.data); - - reader.onloadend = () => - { - this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, (reader.result as ArrayBuffer)); - - this.processReceivedData(); - }; + this.processReceivedData(); } private dispatchConnectionEvent(type: string, event: Event): void