mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 14:36:26 +01:00
Update networking
This commit is contained in:
parent
81cfd5c56f
commit
02f698f8a9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user