New websocket endpoints
This commit is contained in:
parent
7d91dcd500
commit
47eee7e930
@ -157,15 +157,15 @@ export class ApiManager {
|
|||||||
|
|
||||||
// mtpLogOut
|
// mtpLogOut
|
||||||
public async logOut() {
|
public async logOut() {
|
||||||
const storageKeys: Array<string> = [];
|
const storageKeys: Array<`dc${TrueDcId}_auth_key`> = [];
|
||||||
|
|
||||||
const prefix = 'dc';
|
const prefix = 'dc';
|
||||||
for(let dcId = 1; dcId <= 5; dcId++) {
|
for(let dcId = 1; dcId <= 5; dcId++) {
|
||||||
storageKeys.push(prefix + dcId + '_auth_key');
|
storageKeys.push(prefix + dcId + '_auth_key' as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebPushApiManager.forceUnsubscribe(); // WARNING // moved to worker's master
|
// WebPushApiManager.forceUnsubscribe(); // WARNING // moved to worker's master
|
||||||
const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key as any)));
|
const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key)));
|
||||||
|
|
||||||
const logoutPromises: Promise<any>[] = [];
|
const logoutPromises: Promise<any>[] = [];
|
||||||
for(let i = 0; i < storageResult.length; i++) {
|
for(let i = 0; i < storageResult.length; i++) {
|
||||||
|
@ -22,6 +22,7 @@ import TcpObfuscated from './transports/tcpObfuscated';
|
|||||||
import { isSafari } from '../../helpers/userAgent';
|
import { isSafari } from '../../helpers/userAgent';
|
||||||
import { isWebWorker } from '../../helpers/context';
|
import { isWebWorker } from '../../helpers/context';
|
||||||
import SocketProxied from './transports/socketProxied';
|
import SocketProxied from './transports/socketProxied';
|
||||||
|
import App from '../../config/app';
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
||||||
export type TransportType = 'websocket' | 'https' | 'http';
|
export type TransportType = 'websocket' | 'https' | 'http';
|
||||||
@ -56,10 +57,9 @@ export class DcConfigurator {
|
|||||||
public chosenServers: Servers = {} as any;
|
public chosenServers: Servers = {} as any;
|
||||||
|
|
||||||
/// #if !MTPROTO_HTTP
|
/// #if !MTPROTO_HTTP
|
||||||
private transportSocket = (dcId: number, connectionType: ConnectionType) => {
|
private transportSocket = (dcId: number, connectionType: ConnectionType, suffix: string) => {
|
||||||
const subdomain = this.sslSubdomains[dcId - 1];
|
|
||||||
const path = 'apiws' + TEST_SUFFIX;
|
const path = 'apiws' + TEST_SUFFIX;
|
||||||
const chosenServer = 'wss://' + subdomain + '.web.telegram.org/' + path;
|
const chosenServer = `wss://${App.suffix.toLowerCase()}ws${dcId}${suffix}.web.telegram.org/${path}`;
|
||||||
const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : '';
|
const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : '';
|
||||||
|
|
||||||
const retryTimeout = connectionType === 'client' ? 10000 : 10000;
|
const retryTimeout = connectionType === 'client' ? 10000 : 10000;
|
||||||
@ -71,7 +71,7 @@ export class DcConfigurator {
|
|||||||
/// #endif
|
/// #endif
|
||||||
|
|
||||||
/// #if MTPROTO_HTTP_UPLOAD || MTPROTO_HTTP
|
/// #if MTPROTO_HTTP_UPLOAD || MTPROTO_HTTP
|
||||||
private transportHTTP = (dcId: number, connectionType: ConnectionType) => {
|
private transportHTTP = (dcId: number, connectionType: ConnectionType, suffix: string) => {
|
||||||
if(Modes.ssl || !Modes.http) {
|
if(Modes.ssl || !Modes.http) {
|
||||||
const subdomain = this.sslSubdomains[dcId - 1] + (connectionType !== 'client' ? '-1' : '');
|
const subdomain = this.sslSubdomains[dcId - 1] + (connectionType !== 'client' ? '-1' : '');
|
||||||
const path = Modes.test ? 'apiw_test1' : 'apiw1';
|
const path = Modes.test ? 'apiw_test1' : 'apiw1';
|
||||||
@ -112,12 +112,14 @@ export class DcConfigurator {
|
|||||||
if(!transports.length || !reuse/* || (upload && transports.length < 1) */) {
|
if(!transports.length || !reuse/* || (upload && transports.length < 1) */) {
|
||||||
let transport: MTTransport;
|
let transport: MTTransport;
|
||||||
|
|
||||||
|
const suffix = connectionType === 'client' ? '' : '-1';
|
||||||
|
|
||||||
/// #if MTPROTO_HTTP_UPLOAD
|
/// #if MTPROTO_HTTP_UPLOAD
|
||||||
transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType);
|
transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType, suffix);
|
||||||
/// #elif !MTPROTO_HTTP
|
/// #elif !MTPROTO_HTTP
|
||||||
transport = this.transportSocket(dcId, connectionType);
|
transport = this.transportSocket(dcId, connectionType, suffix);
|
||||||
/// #else
|
/// #else
|
||||||
transport = this.transportHTTP(dcId, connectionType);
|
transport = this.transportHTTP(dcId, connectionType, suffix);
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
||||||
if(!transport) {
|
if(!transport) {
|
||||||
|
Loading…
Reference in New Issue
Block a user