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 = () => {
|
||||
this.log('networker drain', networker);
|
||||
|
||||
this.log('networker drain', networker.dcId);
|
||||
|
||||
networker.onDrain = undefined;
|
||||
const idx = networkers.indexOf(networker);
|
||||
networkers.splice(idx, 1);
|
||||
networkerFactory.removeNetworker(networker);
|
||||
networker.destroy();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import Schema from './schema';
|
||||
import timeManager from './timeManager';
|
||||
import networkerFactory from './networkerFactory';
|
||||
import { logger, LogTypes } from '../logger';
|
||||
import { assumeType, InvokeApiOptions } from '../../types';
|
||||
import { InvokeApiOptions } from '../../types';
|
||||
import { longToBytes } from '../crypto/crypto_utils';
|
||||
import MTTransport from './transports/transport';
|
||||
import { convertToUint8Array, bufferConcat, bytesCmp, bytesToHex } from '../../helpers/bytes';
|
||||
@ -370,8 +370,8 @@ export default class MTPNetworker {
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
assumeType<TcpObfuscated>(this.transport);
|
||||
this.transport.destroy();
|
||||
//assumeType<TcpObfuscated>(this.transport);
|
||||
(this.transport as TcpObfuscated).destroy();
|
||||
}
|
||||
|
||||
// private sendPingDelayDisconnect = () => {
|
||||
|
@ -23,6 +23,13 @@ export class NetworkerFactory {
|
||||
public akStopped = false;
|
||||
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) {
|
||||
this.updatesProcessor = callback;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ export default class Socket extends EventListenerBase<{
|
||||
return;
|
||||
}
|
||||
|
||||
this.log.error('close execution');
|
||||
this.log('close execution');
|
||||
|
||||
try {
|
||||
this.ws.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user