Update networking

This commit is contained in:
Bill 2023-07-01 20:18:10 -04:00
parent 81cfd5c56f
commit 02f698f8a9

View File

@ -87,6 +87,7 @@ export class SocketConnection extends EventDispatcher implements IConnection
this._dataBuffer = new ArrayBuffer(0); this._dataBuffer = new ArrayBuffer(0);
this._socket = new WebSocket(socketUrl); this._socket = new WebSocket(socketUrl);
this._socket.binaryType = 'arraybuffer';
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen); this._socket.addEventListener(WebSocketEventEnum.CONNECTION_OPENED, this.onOpen);
this._socket.addEventListener(WebSocketEventEnum.CONNECTION_CLOSED, this.onClose); 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); //this.dispatchConnectionEvent(SocketConnectionEvent.CONNECTION_MESSAGE, event);
const reader = new FileReader(); this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, event.data);
reader.readAsArrayBuffer(event.data); this.processReceivedData();
reader.onloadend = () =>
{
this._dataBuffer = this.concatArrayBuffers(this._dataBuffer, (reader.result as ArrayBuffer));
this.processReceivedData();
};
} }
private dispatchConnectionEvent(type: string, event: Event): void private dispatchConnectionEvent(type: string, event: Event): void