mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-31 03:12:35 +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._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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user