Release networker on drain
This commit is contained in:
parent
d031ff7db5
commit
93cb272fde
@ -273,13 +273,15 @@ export class ApiManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(networker.isFileNetworker) {
|
if(transportType === 'websocket' && networker.isFileNetworker) {
|
||||||
networker.onDrain = () => {
|
networker.onDrain = () => {
|
||||||
this.log('networker drain', networker);
|
this.log('networker drain', networker.dcId);
|
||||||
|
|
||||||
networker.onDrain = undefined;
|
networker.onDrain = undefined;
|
||||||
const idx = networkers.indexOf(networker);
|
const idx = networkers.indexOf(networker);
|
||||||
networkers.splice(idx, 1);
|
networkers.splice(idx, 1);
|
||||||
|
networkerFactory.removeNetworker(networker);
|
||||||
|
networker.destroy();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import Schema from './schema';
|
|||||||
import timeManager from './timeManager';
|
import timeManager from './timeManager';
|
||||||
import networkerFactory from './networkerFactory';
|
import networkerFactory from './networkerFactory';
|
||||||
import { logger, LogTypes } from '../logger';
|
import { logger, LogTypes } from '../logger';
|
||||||
import { assumeType, InvokeApiOptions } from '../../types';
|
import { InvokeApiOptions } from '../../types';
|
||||||
import { longToBytes } from '../crypto/crypto_utils';
|
import { longToBytes } from '../crypto/crypto_utils';
|
||||||
import MTTransport from './transports/transport';
|
import MTTransport from './transports/transport';
|
||||||
import { convertToUint8Array, bufferConcat, bytesCmp, bytesToHex } from '../../helpers/bytes';
|
import { convertToUint8Array, bufferConcat, bytesCmp, bytesToHex } from '../../helpers/bytes';
|
||||||
@ -370,8 +370,8 @@ export default class MTPNetworker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
assumeType<TcpObfuscated>(this.transport);
|
//assumeType<TcpObfuscated>(this.transport);
|
||||||
this.transport.destroy();
|
(this.transport as TcpObfuscated).destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private sendPingDelayDisconnect = () => {
|
// private sendPingDelayDisconnect = () => {
|
||||||
|
@ -23,6 +23,13 @@ export class NetworkerFactory {
|
|||||||
public akStopped = false;
|
public akStopped = false;
|
||||||
public userAgent = navigator.userAgent;
|
public userAgent = navigator.userAgent;
|
||||||
|
|
||||||
|
public removeNetworker(networker: MTPNetworker) {
|
||||||
|
const idx = this.networkers.indexOf(networker);
|
||||||
|
if(idx !== -1) {
|
||||||
|
this.networkers.splice(idx, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public setUpdatesProcessor(callback: (obj: any) => void) {
|
public setUpdatesProcessor(callback: (obj: any) => void) {
|
||||||
this.updatesProcessor = callback;
|
this.updatesProcessor = callback;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ export default class Socket extends EventListenerBase<{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log.error('close execution');
|
this.log('close execution');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.ws.close();
|
this.ws.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user