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