863
864
constructor(opts: PersistentProtocolOptions) {
865
>
this._loadEstimator = opts.loadEstimator ?? LoadEstimator.getInstance();
ipc.net.ts
866
>
this._shouldSendKeepAlive = opts.sendKeepAlive ?? true;
867
>
this._isReconnecting = false;
868
>
this._outgoingUnackMsg = new Queue<ProtocolMessage>();
869
>
this._outgoingMsgId = 0;
870
>
this._outgoingAckId = 0;
871
>
this._outgoingAckTimeout = null;
872
>
873
>
this._incomingMsgId = 0;
874
>
this._incomingAckId = 0;
875
>
this._incomingMsgLastTime = 0;
876
>
this._incomingAckTimeout = null;
877
>
878
>
this._lastReplayRequestTime = 0;
879
>
this._lastSocketTimeoutTime = Date.now();
880
>
881
>
this._socketDisposables = new DisposableStore();
882
>
this._socket = opts.socket;
883
>
this._socketWriter = this._socketDisposables.add(new ProtocolWriter(this._socket));
884
>
this._socketReader = this._socketDisposables.add(new ProtocolReader(this._socket));
885
>
this._socketDisposables.add(this._socketReader.onMessage(msg => this._receiveMessage(msg)));
886
>
this._socketDisposables.add(this._socket.onClose(e => this._onSocketClose.fire(e)));
887
>
888
>
if (opts.initialChunk) {
889
this._socketReader.acceptChunk(opts.initialChunk);
890
}
892
>
if (this._shouldSendKeepAlive) {
893
this._keepAliveInterval = setInterval(() => {
894
this._sendKeepAlive();
895
}, ProtocolConstants.KeepAliveSendTime);
897
this._keepAliveInterval = null;
898
}
900
901
dispose(): void {
903
clearTimeout(this._outgoingAckTimeout);
904
this._outgoingAckTimeout = null;
905
}
907
clearTimeout(this._incomingAckTimeout);
908
this._incomingAckTimeout = null;
909
}
911
clearInterval(this._keepAliveInterval);
912
this._keepAliveInterval = null;
913
}
914
>
this._socketDisposables.dispose();
ipc.net.ts
915
>
}
916
917
drain(): Promise<void> {