1411 lines
62 KiB
TypeScript
1411 lines
62 KiB
TypeScript
/* Metro module 12491; source: modules/gateway/GatewaySocket.tsx; dependencies: [57, 5, 6, 7, 15, 17, 18, 691, 661, 3, 12492, 12494, 672, 561, 12495, 12497, 12503, 12505, 12524, 20, 14, 4488, 12502, 477, 507, 683, 44, 566, 5231, 5237, 5240, 5238, 12525, 12526, 12508, 652, 4826, 4831, 1216, 694, 2] */
|
|
function _fun95051(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#95051, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:6, offset: 0x0212fe16, size: 542 bytes, params: 8, frame: 22
|
|
let env0_0 = require;
|
|
const noop_95055 = function() {
|
|
};
|
|
const withGatewayCompressionHandler = function(a0, a1, a2) {
|
|
var env0_0 = a0;
|
|
var env0_1 = a1;
|
|
var env0_2 = a2;
|
|
var env0_3 = 0;
|
|
a0.dataReady(_fun95057);
|
|
var env0_4 = false;
|
|
return _fun95058;
|
|
};
|
|
const byteSize = function(a0) {
|
|
return a0 == null ? 0 : typeof a0 === 'string' ? a0.length : a0.byteLength;
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let env0_4 = importDefault(57) /* metro dependency 57 */;
|
|
const env0_5 = importDefault(5) /* metro dependency 5 */;
|
|
const env0_6 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_7 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_8 = importDefault(15) /* metro dependency 15 */;
|
|
const env0_9 = importDefault(17) /* metro dependency 17 */;
|
|
const env0_10 = importDefault(18) /* metro dependency 18 */;
|
|
const developerOptionsStore = importDefault(691) /* metro dependency 691: DeveloperOptionsStore */;
|
|
let value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_12 = value.AnalyticEvents;
|
|
const env0_13 = value.Endpoints;
|
|
value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('GatewaySocket');
|
|
value = importDefault(12492) /* metro dependency 12492: GatewayEncoding */;
|
|
value = new value();
|
|
let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
const SECOND = Millis.SECOND;
|
|
const env0_17 = 30 * SECOND;
|
|
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
let MINUTE = Millis.MINUTE;
|
|
const env0_18 = 3 * MINUTE;
|
|
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
MINUTE = Millis.MINUTE;
|
|
const env0_19 = 1 * MINUTE;
|
|
const GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const env0_20 = GLOBAL_ENV.GATEWAY_ENDPOINT;
|
|
value = importDefault(12495) /* metro dependency 12495: GatewaySocketOpCodes */;
|
|
value = _fun95060(value);
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/gateway/GatewaySocket.tsx');
|
|
exports.default = value;
|
|
exports.setAccountSwitchUserId = function(a0) {
|
|
env0_16 = a0;
|
|
};
|
|
}
|
|
|
|
function _isNativeReflectConstruct_95052() { // fn#95052, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:221, offset: 0x02130034, size: 98 bytes, params: 1, frame: 18
|
|
var Boolean;
|
|
var prototype;
|
|
var valueOf;
|
|
var call;
|
|
var Reflect;
|
|
var construct;
|
|
var closure;
|
|
var value;
|
|
var error;
|
|
try {
|
|
Boolean = global.Boolean;
|
|
prototype = Boolean.prototype;
|
|
valueOf = prototype.valueOf;
|
|
call = valueOf.call;
|
|
Reflect = global.Reflect;
|
|
construct = Reflect.construct;
|
|
Boolean = global.Boolean;
|
|
closure = function() {
|
|
};
|
|
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
|
|
value = Reflect.apply(call, valueOf, [value]);
|
|
var result = !value;
|
|
} catch (error) {
|
|
}
|
|
return (_isNativeReflectConstruct_95052_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function withGatewayCompressionHandler(a0, a1, a2) { // fn#95056, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:583, offset: 0x02130096, size: 64 bytes, params: 4, frame: 12
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const env0_2 = a2;
|
|
a0.dataReady(_fun95057);
|
|
return _fun95058;
|
|
}
|
|
|
|
function _fun95060(a0) { // fn#95060, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:977, offset: 0x021301b9, size: 1214 bytes, params: 2, frame: 17
|
|
const closure = GatewaySocket;
|
|
env0_10(closure, a0);
|
|
const binding = env0_7;
|
|
const items2 = [{key: 'connectionState', get: function() {
|
|
return this.connectionState_;
|
|
}, set: set_95064}];
|
|
items2[1] = {key: 'addAnalytics', value: function(a0) {
|
|
var r2;
|
|
var object = {};
|
|
copyDataProperties(object, a0, copyDataProperties(object, this.analytics, r2));
|
|
this.analytics = object;
|
|
}};
|
|
items2[2] = {key: 'setResumeUrl', value: value_95066};
|
|
items2[3] = {key: 'handleActiveStateChange', value: value_95067};
|
|
items2[4] = {key: 'handleUpdateTimeSpentSessionId', value: function(a0, a1, a2) {
|
|
if (this.connectionState_ === importDefault(dependencyMap[16]).SESSION_ESTABLISHED) {
|
|
this.send(require(dependencyMap[14]).Opcode.UPDATE_TIME_SPENT_SESSION_ID, {initialization_timestamp: a0,
|
|
session_id: a1, client_launch_id: a2});
|
|
this._sendHeartbeat();
|
|
}
|
|
}};
|
|
items2[5] = {key: '_connect', value: value_95069};
|
|
items2[6] = {key: '_handleHello', value: value_95080};
|
|
items2[7] = {key: '_handleReconnect', value: value_95081};
|
|
items2[8] = {key: '_handleInvalidSession', value: value_95083};
|
|
items2[9] = {key: '_handleDispatch', value: value_95084};
|
|
items2[10] = {key: 'handleResumeDispatched', value: value_95085};
|
|
items2[11] = {key: 'handleReadyDispatched', value: function() {
|
|
this.didForceClearGuildHashes = false;
|
|
this.hasConnectedOnce = true;
|
|
}};
|
|
items2[12] = {key: '_getGatewayUrl', value: function() {
|
|
return this.resumeUrl ?? GATEWAY_ENDPOINT;
|
|
}};
|
|
items2[13] = {key: '_handleHeartbeatReceive', value: function() {
|
|
var property;
|
|
this._sendHeartbeat();
|
|
if (this.heartbeater != null && this.heartbeatInterval != null) {
|
|
property = global.clearInterval;
|
|
property(this.heartbeater);
|
|
property = global.setInterval;
|
|
this.heartbeater = property(this._doHeartbeatInterval.bind(this), this.heartbeatInterval);
|
|
}
|
|
}};
|
|
items2[14] = {key: '_handleHeartbeatAck', value: value_95089};
|
|
items2[15] = {key: '_handleHeartbeatTimeout', value: value_95090};
|
|
items2[16] = {key: '_handleClose', value: value_95093};
|
|
items2[17] = {key: '_tryDetectInvalidIOSToken', value: value_95095};
|
|
items2[18] = {key: '_reset', value: value_95098};
|
|
items2[19] = {key: '_sendHeartbeatIfDue', value: function() {
|
|
var r0;
|
|
var lastHeartbeatTime;
|
|
var value;
|
|
if (this.heartbeatInterval != null) {
|
|
if (this.heartbeater != null) {
|
|
lastHeartbeatTime = this.lastHeartbeatTime;
|
|
value = lastHeartbeatTime != null;
|
|
if (value) {
|
|
value = global.Date.now() - lastHeartbeatTime;
|
|
value = value > this.heartbeatInterval + 5000;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
if (r0) {
|
|
this._sendHeartbeat();
|
|
}
|
|
}
|
|
}
|
|
}};
|
|
items2[20] = {key: '_doHeartbeatInterval', value: function() {
|
|
if (this.heartbeatAck) {
|
|
this.heartbeatAck = false;
|
|
this._sendHeartbeat();
|
|
} else if (this.expeditedHeartbeatTimeout === null) {
|
|
this._handleHeartbeatTimeout();
|
|
}
|
|
}};
|
|
items2[21] = {key: '_startHeartbeater', value: value_95101};
|
|
items2[22] = {key: '_stopHeartbeater', value: function() {
|
|
if (this.heartbeater !== null) {
|
|
global.clearInterval(this.heartbeater);
|
|
this.heartbeater = null;
|
|
}
|
|
if (this.initialHeartbeatTimeout !== null) {
|
|
global.clearTimeout(this.initialHeartbeatTimeout);
|
|
this.initialHeartbeatTimeout = null;
|
|
}
|
|
if (this.expeditedHeartbeatTimeout !== null) {
|
|
global.clearTimeout(this.expeditedHeartbeatTimeout);
|
|
this.expeditedHeartbeatTimeout = null;
|
|
}
|
|
}};
|
|
items2[23] = {key: '_clearHelloTimeout', value: function() {
|
|
if (this.helloTimeout != null) {
|
|
global.clearTimeout(this.helloTimeout);
|
|
this.helloTimeout = null;
|
|
}
|
|
}};
|
|
items2[24] = {key: '_cleanup', value: value_95105};
|
|
items2[25] = {key: '_doResume', value: value_95106};
|
|
const env0_0 = env0_5(_fun95108);
|
|
items2[26] = {key: '_doIdentify', value: value_95109};
|
|
items2[27] = {key: '_doFastConnectIdentify', value: value_95110};
|
|
items2[28] = {key: '_doResumeOrIdentify', value: value_95111};
|
|
items2[29] = {key: '_updateLastHeartbeatAckTime', value: function() {
|
|
var Date = global.Date;
|
|
this.lastHeartbeatAckTime = Date.now();
|
|
}};
|
|
items2[30] = {key: '_consumeQOSPayload', value: function() {
|
|
var currentPayload = this.heartbeatQOSState.currentPayload;
|
|
this.heartbeatQOSState.currentPayload = this.heartbeatQOSState.upcomingState ?? this.heartbeatQOSState.currentPayload;
|
|
this.heartbeatQOSState.upcomingState = null;
|
|
return currentPayload;
|
|
}};
|
|
items2[31] = {key: '_sendHeartbeat', value: function() {
|
|
this.send(require(dependencyMap[14]).Opcode.QOS_HEARTBEAT, {seq: this.seq, qos: this._consumeQOSPayload()},
|
|
false);
|
|
this.lastHeartbeatTime = global.Date.now();
|
|
}};
|
|
items2[32] = {key: 'getLogger', value: value_95115};
|
|
items2[33] = {key: 'willReconnect', value: function() {
|
|
return this.connectionState === importDefault(dependencyMap[16]).WILL_RECONNECT;
|
|
}};
|
|
items2[34] = {key: 'isClosed', value: function() {
|
|
return this.connectionState === importDefault(dependencyMap[16]).CLOSED;
|
|
}};
|
|
items2[35] = {key: 'isSessionEstablished', value: value_95118};
|
|
items2[36] = {key: 'isConnected', value: value_95119};
|
|
items2[37] = {key: 'connect', value: value_95120};
|
|
items2[38] = {key: 'resetSocketAndClearCacheOnError', value: value_95121};
|
|
items2[39] = {key: 'resetSocketOnDispatchError', value: function(a0) {
|
|
var r5;
|
|
var r3;
|
|
var message;
|
|
var value = a0.error.message != null;
|
|
if (value) {
|
|
message = a0.error.message;
|
|
value = message.indexOf('Guild data was missing from store');
|
|
value = value >= 0;
|
|
r3 = value;
|
|
r5 = message;
|
|
} else {
|
|
r3 = value;
|
|
}
|
|
var object = {};
|
|
copyDataProperties(object, a0, r5);
|
|
object['sentry'] = !r3;
|
|
this.resetSocketAndClearCacheOnError(object);
|
|
}};
|
|
items2[40] = {key: 'close', value: value_95128};
|
|
items2[41] = {key: 'networkStateChange', value: function(a0, a1) {
|
|
var value = a2;
|
|
this.expeditedHeartbeat(a0, a1, !(value !== undefined) || value, false);
|
|
}};
|
|
items2[42] = {key: 'expeditedHeartbeat', value: value_95132};
|
|
items2[43] = {key: 'resetBackoff', value: value_95134};
|
|
return binding(closure, items2);
|
|
}
|
|
|
|
function _fun95057(a0) { // fn#95057, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:650, offset: 0x021300d6, size: 46 bytes, params: 2, frame: 14
|
|
var value;
|
|
var binding;
|
|
var defaultImport;
|
|
var error;
|
|
try {
|
|
value = environment;
|
|
binding = env0_3;
|
|
defaultImport = importDefault(a0, binding);
|
|
} catch (error) {
|
|
env0_3 = 0;
|
|
throw error;
|
|
}
|
|
return defaultImport;
|
|
}
|
|
|
|
function _fun95058(a0) { // fn#95058, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:704, offset: 0x02130104, size: 138 bytes, params: 2, frame: 18
|
|
var value;
|
|
var binding;
|
|
var value2;
|
|
var error;
|
|
const data = a0.data;
|
|
if (a0.raw_length != null) {
|
|
binding = env0_3;
|
|
env0_3 = binding + a0.raw_length;
|
|
} else {
|
|
binding = env0_3;
|
|
value2 = environment.__proto__;
|
|
env0_3 = binding + byteSize(data);
|
|
}
|
|
try {
|
|
value = environment;
|
|
binding = env0_0;
|
|
binding.feed(data);
|
|
} catch (error) {
|
|
if (!env0_4) {
|
|
env0_4 = true;
|
|
require(false, 0, 'A decompression error occurred');
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
function GatewaySocket() { // fn#95061, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:989, offset: 0x02130677, size: 524 bytes, params: 1, frame: 22
|
|
let binding = env1_6;
|
|
binding(this, GatewaySocket);
|
|
const value3 = env1_9(GatewaySocket);
|
|
const value6 = env1_8(this, _isNativeReflectConstruct_95052() ? global.Reflect.construct(value3, [],
|
|
env1_9(this).constructor) : value3.apply(this, undefined));
|
|
const defaultImport = importDefault(561) /* metro dependency 561: Backoff */;
|
|
binding = env1_19;
|
|
const value7 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}});
|
|
const defaultImport4 = new defaultImport(1000, binding);
|
|
value6.dispatchExceptionBackoff = defaultImport4 instanceof Object ? defaultImport4 : value7;
|
|
value6.dispatchSuccessTimer = 0;
|
|
value6.didForceClearGuildHashes = false;
|
|
value6.identifyUncompressedByteSize = 0;
|
|
value6.identifyCompressedByteSize = 0;
|
|
value6.analytics = {};
|
|
value6.identifyCount = 0;
|
|
value6.resumeUrl = null;
|
|
value6.iosGoingAwayEventCount = 0;
|
|
value6.heartbeatQOSState = {'currentPayload': null, 'upcomingState': null};
|
|
value6.send = send_95062;
|
|
const defaultImport2 = importDefault(12497) /* metro dependency 12497: GatewaySocketDispatcher */;
|
|
const value10 = Object.create(defaultImport2.prototype, {constructor: {value: defaultImport2}});
|
|
const defaultImport22 = new defaultImport2(value6);
|
|
value6.dispatcher = defaultImport22 instanceof Object ? defaultImport22 : value10;
|
|
const defaultImport3 = defaultImport;
|
|
const value13 = Object.create(defaultImport3.prototype, {constructor: {value: defaultImport3}});
|
|
const defaultImport32 = new defaultImport3(1000, 60000);
|
|
value6.gatewayBackoff = defaultImport32 instanceof Object ? defaultImport32 : value13;
|
|
const CLOSED = (importDefault(12503) /* metro dependency 12503: ConnectionState */).CLOSED;
|
|
value6.connectionState_ = CLOSED;
|
|
value6.webSocket = null;
|
|
value6.seq = 0;
|
|
value6.sessionId = null;
|
|
value6.token = null;
|
|
value6.initialHeartbeatTimeout = null;
|
|
value6.expeditedHeartbeatTimeout = null;
|
|
value6.lastHeartbeatTime = null;
|
|
value6.lastHeartbeatAckTime = null;
|
|
value6.helloTimeout = null;
|
|
value6.heartbeatInterval = null;
|
|
value6.heartbeater = null;
|
|
value6.heartbeatAck = true;
|
|
value6.connectionStartTime = 0;
|
|
value6.identifyStartTime = 0;
|
|
value6.nextReconnectIsImmediate = false;
|
|
value6.compressionHandler = (require(12505) /* metro dependency 12505: GatewayCompressionHandler */).getCompressionHandler(env1_15);
|
|
value6.hasConnectedOnce = false;
|
|
value6.isFastConnect = false;
|
|
value6.identifyCount = 0;
|
|
value6.iosGoingAwayEventCount = 0;
|
|
return value6;
|
|
}
|
|
|
|
function set_95064(a0) { // fn#95064, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:2488, offset: 0x0213096c, size: 58 bytes, params: 2, frame: 13
|
|
env1_14.verbose('Setting connection state to ' + a0);
|
|
this.connectionState_ = a0;
|
|
}
|
|
|
|
function value_95066(a0) { // fn#95066, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:2678, offset: 0x021309cc, size: 118 bytes, params: 2, frame: 15
|
|
let value = a0;
|
|
const r1 = value != null && value.endsWith('/') ? value.substring(0, value.length - 1) : value;
|
|
if (r1 !== null) {
|
|
value = environment.__proto__;
|
|
env1_14.verbose('Updating resume url to ' + r1);
|
|
}
|
|
this.resumeUrl = r1;
|
|
}
|
|
|
|
function value_95067(a0) { // fn#95067, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:2853, offset: 0x02130a42, size: 230 bytes, params: 2, frame: 19
|
|
var Set;
|
|
var reasons;
|
|
var items2;
|
|
var value2;
|
|
var set;
|
|
let currentPayload = this.heartbeatQOSState.currentPayload;
|
|
let r2 = currentPayload != null && currentPayload.active;
|
|
value = !r2;
|
|
if (this.heartbeatQOSState.currentPayload == null) {
|
|
this.heartbeatQOSState.currentPayload = a0;
|
|
}
|
|
currentPayload = this.heartbeatQOSState.currentPayload;
|
|
if (a0.active) {
|
|
currentPayload.active = true;
|
|
Set = global.Set;
|
|
reasons = currentPayload.reasons;
|
|
items2 = [];
|
|
value2 = arraySpread(items2, reasons, 0, undefined);
|
|
reasons = a0.reasons;
|
|
arraySpread(items2, reasons, value2, undefined);
|
|
set = new Set();
|
|
items2 = [];
|
|
arraySpread(items2, set, 0, undefined);
|
|
currentPayload.reasons = items2.sort();
|
|
r2 = r2 ? value : this.isSessionEstablished();
|
|
if (r2) {
|
|
this._sendHeartbeat();
|
|
}
|
|
}
|
|
this.heartbeatQOSState.upcomingState = a0;
|
|
}
|
|
|
|
function value_95069() { // fn#95069, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:3522, offset: 0x02130ba8, size: 665 bytes, params: 1, frame: 32
|
|
var binding;
|
|
var compressionHandler;
|
|
var name;
|
|
var value4;
|
|
var API_VERSION;
|
|
var Date;
|
|
var setTimeout;
|
|
var uRL;
|
|
var searchParams;
|
|
var object2;
|
|
var withGatewayCompressionHandlerBinding;
|
|
let value = this.willReconnect();
|
|
if (value) {
|
|
value = importAll(12524) /* metro dependency 12524: PauseGatewaySocket */;
|
|
if (value.getIsPaused()) {
|
|
env1_14.info('Skipping _connect because socket is paused');
|
|
} else {
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).CONNECTING;
|
|
this.nextReconnectIsImmediate = false;
|
|
compressionHandler = this.compressionHandler;
|
|
value = compressionHandler.getAlgorithm();
|
|
binding = env1_15;
|
|
name = binding.getName();
|
|
value4 = this._getGatewayUrl();
|
|
API_VERSION = global.window.GLOBAL_ENV.API_VERSION;
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Socket._connect');
|
|
binding = env1_14;
|
|
binding.info('[CONNECT] ' + value4 + ', encoding: ' + name + ', version: ' + API_VERSION + ', compression: ' + (value ?? 'none'));
|
|
if (this.webSocket !== null) {
|
|
env1_14.error('_connect called with already existing websocket');
|
|
this._cleanup(function(a0) {
|
|
return a0.close(4000);
|
|
});
|
|
}
|
|
Date = global.Date;
|
|
this.connectionStartTime = Date.now();
|
|
setTimeout = global.setTimeout;
|
|
binding = env1_17;
|
|
this.helloTimeout = setTimeout(_fun95071, binding);
|
|
uRL = new global.URL();
|
|
searchParams = uRL.searchParams;
|
|
searchParams.append('encoding', name);
|
|
searchParams = uRL.searchParams;
|
|
searchParams.append('v', API_VERSION.toString());
|
|
if (value != null) {
|
|
uRL.searchParams.append('compress', value);
|
|
}
|
|
object2 = {};
|
|
object2.gatewayURL = uRL.toString();
|
|
object2.newCallback = newCallback;
|
|
object2.onOpen = onOpen;
|
|
withGatewayCompressionHandlerBinding = withGatewayCompressionHandler;
|
|
compressionHandler = this.compressionHandler;
|
|
value = this._handleClose.bind(this);
|
|
object2.onMessage = withGatewayCompressionHandlerBinding(compressionHandler, value, _fun95077);
|
|
object2.onError = onError_95078;
|
|
object2.onClose = onClose_95079;
|
|
newOrTakeoverWebSocket(object2);
|
|
}
|
|
} else {
|
|
env1_14.verbose('Skipping _connect because willReconnect is false');
|
|
}
|
|
}
|
|
|
|
function value_95080(a0) { // fn#95080, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7334, offset: 0x021316d9, size: 152 bytes, params: 2, frame: 25
|
|
const heartbeat_interval = a0.heartbeat_interval;
|
|
this.heartbeatInterval = heartbeat_interval;
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
value -= this.connectionStartTime;
|
|
const binding = env1_14;
|
|
binding.verbose('[HELLO] via ' + (require(12502) /* metro dependency 12502: GatewaySocketAnalytics */).getConnectionPath(a0) + ', heartbeat interval: ' + heartbeat_interval + ', took ' + value + ' ms');
|
|
this._startHeartbeater();
|
|
}
|
|
|
|
function value_95081() { // fn#95081, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7589, offset: 0x02131771, size: 93 bytes, params: 1, frame: 13
|
|
env1_14.verbose('[RECONNECT] gateway requested I reconnect.');
|
|
this._cleanup(function(a0) {
|
|
return a0.close(4000);
|
|
});
|
|
const WILL_RECONNECT = (importDefault(12503) /* metro dependency 12503: ConnectionState */).WILL_RECONNECT;
|
|
this.connectionState = WILL_RECONNECT;
|
|
this._connect();
|
|
}
|
|
|
|
function value_95083(a0) { // fn#95083, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7787, offset: 0x021317ce, size: 76 bytes, params: 2, frame: 14
|
|
const value = environment.__proto__;
|
|
const binding = env1_14;
|
|
binding.info('[INVALID_SESSION]' + (a0 ? ' can resume)' : ''));
|
|
if (a0) {
|
|
this._doResumeOrIdentify();
|
|
} else {
|
|
this._doIdentify();
|
|
}
|
|
}
|
|
|
|
function value_95084(a0, a1, a2) { // fn#95084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7928, offset: 0x0213181a, size: 530 bytes, params: 4, frame: 25
|
|
var binding;
|
|
var verbose;
|
|
var moduleValue;
|
|
var value2;
|
|
var session_id;
|
|
var value3;
|
|
var connectionPath;
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
value -= this.connectionStartTime;
|
|
if (a1 === 'READY') {
|
|
session_id = a0.session_id;
|
|
this.sessionId = session_id;
|
|
value3 = environment.__proto__;
|
|
connectionPath = (require(12502) /* metro dependency 12502: GatewaySocketAnalytics */).getConnectionPath(a0);
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).setServerTrace(connectionPath);
|
|
binding = env1_14;
|
|
binding.info('[READY] took ' + value + 'ms, as ' + session_id);
|
|
binding.verbose('' + connectionPath);
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED;
|
|
this.gatewayBackoff.succeed();
|
|
this.iosGoingAwayEventCount = 0;
|
|
this.setResumeUrl(a0.resume_gateway_url);
|
|
} else if (a1 === 'READY_SUPPLEMENTAL') {
|
|
value2 = environment.__proto__;
|
|
env1_14.info('[READY_SUPPLEMENTAL] took ' + value + 'ms');
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED;
|
|
this.gatewayBackoff.succeed();
|
|
this.iosGoingAwayEventCount = 0;
|
|
} else if (a1 === 'RESUMED') {
|
|
value = environment.__proto__;
|
|
binding = env1_14;
|
|
verbose = binding.verbose;
|
|
moduleValue = require(12502) /* metro dependency 12502: GatewaySocketAnalytics */;
|
|
Reflect.apply(verbose, binding, [moduleValue.getConnectionPath(a0)]);
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED;
|
|
this.gatewayBackoff.succeed();
|
|
this.iosGoingAwayEventCount = 0;
|
|
}
|
|
this.dispatcher.receiveDispatch(a0, a1, a2);
|
|
}
|
|
|
|
function value_95085() { // fn#95085, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:8737, offset: 0x02131a2c, size: 109 bytes, params: 1, frame: 21
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
value -= this.connectionStartTime;
|
|
const binding = env1_14;
|
|
binding.info('[RESUMED] took ' + value + 'ms, replayed ' + this.dispatcher.resumeAnalytics.numEvents + ' events, new seq: ' + this.seq);
|
|
}
|
|
|
|
function value_95089() { // fn#95089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:9383, offset: 0x02131b3a, size: 99 bytes, params: 1, frame: 13
|
|
var value;
|
|
const Date = global.Date;
|
|
this.lastHeartbeatAckTime = Date.now();
|
|
this.heartbeatAck = true;
|
|
if (this.expeditedHeartbeatTimeout !== null) {
|
|
global.clearTimeout(this.expeditedHeartbeatTimeout);
|
|
this.expeditedHeartbeatTimeout = null;
|
|
value = environment.__proto__;
|
|
env1_14.verbose('Expedited heartbeat succeeded');
|
|
}
|
|
}
|
|
|
|
function value_95090() { // fn#95090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:9656, offset: 0x02131b9d, size: 159 bytes, params: 1, frame: 16
|
|
var environment;
|
|
this._cleanup(function(a0) {
|
|
return a0.close(4000);
|
|
});
|
|
let value = environment.__proto__;
|
|
const WILL_RECONNECT = (importDefault(12503) /* metro dependency 12503: ConnectionState */).WILL_RECONNECT;
|
|
this.connectionState = WILL_RECONNECT;
|
|
const value2 = this.gatewayBackoff.fail(_fun95092);
|
|
const binding = env1_14;
|
|
const warn = binding.warn;
|
|
value = value2 / 1000;
|
|
value = value.toFixed(2);
|
|
Reflect.apply(warn, binding, ['[ACK TIMEOUT] reconnecting in ' + value + ' seconds.']);
|
|
}
|
|
|
|
function value_95093(a0, a1, a2) { // fn#95093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:9898, offset: 0x02131c4f, size: 454 bytes, params: 4, frame: 30
|
|
var environment;
|
|
var gatewayBackoff;
|
|
var value2;
|
|
var binding;
|
|
const r4 = a0 || false;
|
|
this._cleanup();
|
|
this.emit('close', {code: a1, reason: a2});
|
|
if (a1 === 4004) {
|
|
value = environment.__proto__;
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).CLOSED;
|
|
env1_14.warn('[WS CLOSED] because of authentication failure, marking as closed.');
|
|
return this._reset(r4, a1, a2);
|
|
}
|
|
this._tryDetectInvalidIOSToken(a1, a2, r4);
|
|
value = environment.__proto__;
|
|
const WILL_RECONNECT = (importDefault(12503) /* metro dependency 12503: ConnectionState */).WILL_RECONNECT;
|
|
this.connectionState = WILL_RECONNECT;
|
|
if (this.nextReconnectIsImmediate) {
|
|
binding = env1_14;
|
|
binding.info('[WS CLOSED] (' + r4.toString() + ', ' + a1 + ', ' + a2 + ') retrying immediately.');
|
|
this._connect();
|
|
} else {
|
|
gatewayBackoff = this.gatewayBackoff;
|
|
value2 = gatewayBackoff.fail(_fun95094);
|
|
binding = env1_14;
|
|
binding.info('[WS CLOSED] (' + r4.toString() + ', ' + a1 + ', ' + a2 + ') retrying in ' + (value2 / 1000).toFixed(2) + ' seconds.');
|
|
gatewayBackoff = this.gatewayBackoff;
|
|
if (gatewayBackoff.fails > 4) {
|
|
this._reset(r4, a1, a2);
|
|
}
|
|
}
|
|
}
|
|
|
|
function value_95095(a0, a1, a2) { // fn#95095, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:10573, offset: 0x02131e15, size: 238 bytes, params: 4, frame: 16
|
|
var environment;
|
|
var iosGoingAwayEventCount;
|
|
var HTTP;
|
|
const env0_1 = a2;
|
|
const value = environment.__proto__;
|
|
if ((require(477) /* metro dependency 477: PlatformUtils */).isIOS() && this.token != null && a0 === 1001 && a1 === 'Stream end encountered') {
|
|
iosGoingAwayEventCount = this.iosGoingAwayEventCount;
|
|
this.iosGoingAwayEventCount = iosGoingAwayEventCount + 1;
|
|
iosGoingAwayEventCount = this.iosGoingAwayEventCount;
|
|
if (iosGoingAwayEventCount === 3) {
|
|
HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
|
|
HTTP.get({url: Endpoints.ME, headers: {authorization: this.token},
|
|
rejectWithError: false}).then(function({status}) {
|
|
var defaultImport = importDefault(dependencyMap[25]);
|
|
var IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED = AnalyticEvents.IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED;
|
|
defaultImport.track(IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED, {api_status_code: status});
|
|
}, _fun95097);
|
|
}
|
|
}
|
|
}
|
|
|
|
function value_95098(a0, a1, a2) { // fn#95098, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:11215, offset: 0x02131fe8, size: 137 bytes, params: 4, frame: 24
|
|
this.sessionId = null;
|
|
this.seq = 0;
|
|
const value = environment.__proto__;
|
|
const binding = env1_14;
|
|
binding.warn('[RESET] (' + a0.toString() + ', ' + a1 + ', ' + a2 + ')');
|
|
this.emit('disconnect', {wasClean: a0, code: a1, reason: a2});
|
|
}
|
|
|
|
function value_95101() { // fn#95101, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:11781, offset: 0x0213210b, size: 192 bytes, params: 1, frame: 18
|
|
var environment;
|
|
const heartbeatInterval = this.heartbeatInterval;
|
|
const value = environment.__proto__;
|
|
(importDefault(44) /* metro dependency 44 */)(heartbeatInterval != null,
|
|
'GatewaySocket: Heartbeat interval should never null here.');
|
|
if (this.initialHeartbeatTimeout !== null) {
|
|
global.clearTimeout(this.initialHeartbeatTimeout);
|
|
}
|
|
if (this.heartbeater !== null) {
|
|
global.clearInterval(this.heartbeater);
|
|
this.heartbeater = null;
|
|
}
|
|
const setTimeout = global.setTimeout;
|
|
const Math = global.Math;
|
|
const floor = Math.floor;
|
|
const Math2 = global.Math;
|
|
this.initialHeartbeatTimeout = setTimeout(_fun95102, Reflect.apply(floor, Math,
|
|
[Math2.random() * heartbeatInterval]));
|
|
}
|
|
|
|
function value_95105(a0) { // fn#95105, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:12802, offset: 0x02132290, size: 199 bytes, params: 2, frame: 16
|
|
var noop_95055Binding;
|
|
const Emitter = (importDefault(566) /* metro dependency 566: flux */).Emitter;
|
|
Emitter.resume();
|
|
this._stopHeartbeater();
|
|
this._clearHelloTimeout();
|
|
const webSocket = this.webSocket;
|
|
this.webSocket = null;
|
|
if (webSocket != null) {
|
|
noop_95055Binding = noop_95055;
|
|
webSocket.onopen = noop_95055Binding;
|
|
webSocket.onmessage = noop_95055Binding;
|
|
webSocket.onerror = noop_95055Binding;
|
|
webSocket.onclose = noop_95055Binding;
|
|
if (a0 != null) {
|
|
a0(webSocket);
|
|
}
|
|
}
|
|
this.gatewayBackoff.cancel();
|
|
this.compressionHandler.close();
|
|
const gatewayCompressionHandlerModule = require(12505) /* metro dependency 12505: GatewayCompressionHandler */;
|
|
const getCompressionHandler = gatewayCompressionHandlerModule.getCompressionHandler;
|
|
this.compressionHandler = Reflect.apply(getCompressionHandler, gatewayCompressionHandlerModule, [env1_15]);
|
|
}
|
|
|
|
function value_95106() { // fn#95106, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:13161, offset: 0x02132357, size: 263 bytes, params: 1, frame: 20
|
|
const RESUMING = (importDefault(12503) /* metro dependency 12503: ConnectionState */).RESUMING;
|
|
this.connectionState = RESUMING;
|
|
const dispatcher = this.dispatcher;
|
|
const gatewaySocketAnalyticsModule = require(12502) /* metro dependency 12502: GatewaySocketAnalytics */;
|
|
const createResumeAnalytics = gatewaySocketAnalyticsModule.createResumeAnalytics;
|
|
const Date = global.Date;
|
|
dispatcher.resumeAnalytics = Reflect.apply(createResumeAnalytics, gatewaySocketAnalyticsModule,
|
|
[Date.now() - this.connectionStartTime]);
|
|
const binding = env1_14;
|
|
binding.info('[RESUME] resuming session ' + (this.sessionId ?? '') + ', seq: ' + this.seq);
|
|
const send = this.send;
|
|
const Opcode = (require(12495) /* metro dependency 12495: GatewaySocketOpCodes */).Opcode;
|
|
const RESUME = Opcode.RESUME;
|
|
Reflect.apply(send, this, [RESUME, {token: this.token, session_id: this.sessionId, seq: this.seq}, false]);
|
|
}
|
|
|
|
function* _fun95108() { // fn#95108, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:13532, offset: 0x02132469, size: 913 bytes, params: 1, frame: 29
|
|
var r11;
|
|
var r10;
|
|
var r12;
|
|
var value3;
|
|
var binding;
|
|
var binding2;
|
|
var IDENTIFYING;
|
|
var value4;
|
|
var Promise;
|
|
var all;
|
|
var value5;
|
|
var isCacheEnabled;
|
|
var object;
|
|
var value8;
|
|
var isCacheEnabled2;
|
|
var value14;
|
|
var value16;
|
|
var property;
|
|
var property2;
|
|
var connectionState;
|
|
var token;
|
|
var properties;
|
|
var presence;
|
|
var binding3;
|
|
var getClientCapabilities;
|
|
var object2;
|
|
var length;
|
|
var value18;
|
|
if (true) {
|
|
this.seq = 0;
|
|
this.sessionId = null;
|
|
value = this.handleIdentify();
|
|
if (value !== null) {
|
|
value3 = environment.__proto__.__proto__;
|
|
binding = env2_1;
|
|
binding2 = env2_3;
|
|
IDENTIFYING = binding(binding2[16]).IDENTIFYING;
|
|
this.connectionState = IDENTIFYING;
|
|
value4 = global.Date.now();
|
|
this.identifyStartTime = value4;
|
|
Promise = global.Promise;
|
|
all = Promise.all;
|
|
binding = env2_0;
|
|
value5 = binding(binding2[28]);
|
|
isCacheEnabled = value5.isCacheEnabled;
|
|
r11 = Reflect.apply(isCacheEnabled, value5, []) ? env2_1(env2_3[29]).getCommittedVersions() : {};
|
|
object = [r11];
|
|
binding = env2_0;
|
|
value8 = binding(env2_3[28]);
|
|
isCacheEnabled = value8.isCacheEnabled;
|
|
r11 = Reflect.apply(isCacheEnabled, value8, []) ? env2_1(env2_3[30]).getCommittedVersions() : {};
|
|
object[1] = r11;
|
|
binding = env2_0;
|
|
isCacheEnabled2 = binding(env2_3[28]).isCacheEnabled();
|
|
r11 = isCacheEnabled2 ? env2_1(env2_3[31]).canUseGuildVersions() : !!isCacheEnabled2;
|
|
object[2] = r11;
|
|
yield Reflect.apply(all, Promise, [object]);
|
|
value14 = undefined;
|
|
if (false) {
|
|
return value14;
|
|
}
|
|
value16 = env2_4(value14, 3);
|
|
property = value16[0];
|
|
property2 = value16[1];
|
|
r10 = value16[2] ? {guild_versions: property, highest_last_message_id: property2.highest_last_message_id,
|
|
read_state_version: property2.read_state_version,
|
|
user_guild_settings_version: property2.user_guild_settings_version,
|
|
user_settings_version: property2.user_settings_version,
|
|
private_channels_version: property2.private_channels_version,
|
|
api_code_version: property2.api_code_version,
|
|
initial_guild_id: property2.initial_guild_id} : {guild_versions: {}};
|
|
connectionState = this.connectionState;
|
|
binding = env2_1;
|
|
IDENTIFYING = binding(env2_3[16]).IDENTIFYING;
|
|
if (connectionState !== IDENTIFYING) {
|
|
env2_14.warn('Skipping identify because connectionState or identifyStartTime has changed');
|
|
} else if (this.identifyStartTime === value4) {
|
|
token = value.token;
|
|
properties = value.properties;
|
|
r12 = properties !== undefined ? properties : {};
|
|
presence = value.presence;
|
|
this.token = token;
|
|
binding = env2_14;
|
|
binding.verbose('[IDENTIFY]');
|
|
object = {token: token};
|
|
binding = env2_0;
|
|
binding3 = env2_3;
|
|
value = binding(binding3[32]);
|
|
getClientCapabilities = value.getClientCapabilities;
|
|
object2 = {};
|
|
object2.useChannelObfuscation = binding(binding3[33]).isChannelMetadataObfuscationEnabled('GatewaySocket');
|
|
object.capabilities = Reflect.apply(getClientCapabilities, value, [object2]);
|
|
object.properties = r12;
|
|
object.presence = presence;
|
|
object.compress = this.compressionHandler.usesLegacyCompression();
|
|
object.client_state = r10;
|
|
value = global.JSON.stringify(object);
|
|
length = value.length;
|
|
this.identifyUncompressedByteSize = length;
|
|
value18 = env2_2(binding3[34]);
|
|
length = value18.deflate(value).length;
|
|
this.identifyCompressedByteSize = length;
|
|
this.identifyCount = this.identifyCount + 1;
|
|
this.send(binding(binding3[14]).Opcode.IDENTIFY, object, false);
|
|
binding = env2_1;
|
|
value = binding(binding3[25]);
|
|
value.track(env2_12.SESSION_START_CLIENT, {});
|
|
} else {
|
|
env2_14.warn('Skipping identify because connectionState or identifyStartTime has changed');
|
|
}
|
|
} else {
|
|
this._handleClose(true, 4004, 'No connection info provided');
|
|
}
|
|
}
|
|
}
|
|
|
|
function value_95110() { // fn#95110, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:15184, offset: 0x021327fa, size: 188 bytes, params: 1, frame: 16
|
|
var Date;
|
|
this.seq = 0;
|
|
this.sessionId = null;
|
|
let value = this.handleIdentify();
|
|
if (value !== null) {
|
|
this.token = value.token;
|
|
value = environment.__proto__;
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).IDENTIFYING;
|
|
Date = global.Date;
|
|
this.identifyStartTime = Date.now();
|
|
this.identifyCount = this.identifyCount + 1;
|
|
env1_14.verbose('[IDENTIFY, fast-connect]');
|
|
this._updateLastHeartbeatAckTime();
|
|
} else {
|
|
this._handleClose(true, 4004, 'No connection info provided');
|
|
}
|
|
}
|
|
|
|
function value_95111() { // fn#95111, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:15559, offset: 0x021328b6, size: 101 bytes, params: 1, frame: 11
|
|
var value2;
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
if (this.sessionId === null) {
|
|
this._doIdentify();
|
|
} else if (this.lastHeartbeatAckTime == null) {
|
|
this._doResume();
|
|
} else {
|
|
value -= this.lastHeartbeatAckTime;
|
|
value2 = environment.__proto__;
|
|
if (value <= env1_18) {
|
|
this._doResume();
|
|
} else {
|
|
this._doIdentify();
|
|
}
|
|
}
|
|
this._updateLastHeartbeatAckTime();
|
|
}
|
|
|
|
function value_95118() { // fn#95118, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:16533, offset: 0x02132a4a, size: 82 bytes, params: 1, frame: 15
|
|
const connectionState = this.connectionState;
|
|
const value = environment.__proto__;
|
|
const SESSION_ESTABLISHED = (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED;
|
|
return connectionState === SESSION_ESTABLISHED || this.connectionState === (importDefault(12503) /* metro dependency 12503: ConnectionState */).RESUMING;
|
|
}
|
|
|
|
function value_95119() { // fn#95119, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:16672, offset: 0x02132a9c, size: 118 bytes, params: 1, frame: 16
|
|
const connectionState = this.connectionState;
|
|
const value = environment.__proto__;
|
|
const IDENTIFYING = (importDefault(12503) /* metro dependency 12503: ConnectionState */).IDENTIFYING;
|
|
let r0 = connectionState === IDENTIFYING || this.connectionState === (importDefault(12503) /* metro dependency 12503: ConnectionState */).RESUMING;
|
|
r0 = !r0 ? this.connectionState === (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED : r0;
|
|
return r0;
|
|
}
|
|
|
|
function value_95120() { // fn#95120, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:16852, offset: 0x02132b12, size: 108 bytes, params: 1, frame: 14
|
|
var r0;
|
|
const isClosed = this.isClosed();
|
|
const binding = env1_14;
|
|
if (isClosed) {
|
|
binding.verbose('.connect() called, new state is WILL_RECONNECT');
|
|
this.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).WILL_RECONNECT;
|
|
this._connect();
|
|
r0 = true;
|
|
} else {
|
|
binding.error('Cannot start a new connection, connection state is not closed');
|
|
r0 = false;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function value_95121({action, error, metricAction, sentry}) { // fn#95121, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:17137, offset: 0x02132b7e, size: 753 bytes, params: 2, frame: 26
|
|
var environment;
|
|
const value = environment.__proto__;
|
|
const binding = env1_14;
|
|
binding.error('resetSocketAndClearCacheOnError during ' + action + ': ' + error.message, error.stack);
|
|
const value3 = (require(652) /* metro dependency 652: ClientModDetectionUtils */).usesClientMods();
|
|
const defaultImport = importDefault(4826) /* metro dependency 4826: MonitoringAgent */;
|
|
const increment = defaultImport.increment;
|
|
const MetricEvents = (require(4831) /* metro dependency 4831: MetricEvents */).MetricEvents;
|
|
const SOCKET_CRASHED = MetricEvents.SOCKET_CRASHED;
|
|
Reflect.apply(increment, defaultImport, [{name: SOCKET_CRASHED, tags: ['action:' + (metricAction ?? action),
|
|
'modded_client:' + value3]}, true]);
|
|
if (sentry !== false) {
|
|
(importDefault(1216) /* metro dependency 1216: SentryUtilsNative */).captureException(error,
|
|
{tags: {socketCrashedAction: action}});
|
|
}
|
|
const defaultImport3 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
const track = defaultImport3.track;
|
|
const GATEWAY_SOCKET_RESET = AnalyticEvents.GATEWAY_SOCKET_RESET;
|
|
Reflect.apply(track, defaultImport3, [GATEWAY_SOCKET_RESET, {error_message: error.message, error_stack: error.stack,
|
|
has_client_mods: value3, action: action}]);
|
|
this._cleanup(function(a0) {
|
|
return a0.close();
|
|
});
|
|
this._reset(true, 1000, 'Resetting socket due to error.');
|
|
this.dispatcher.clear();
|
|
const WILL_RECONNECT = (importDefault(12503) /* metro dependency 12503: ConnectionState */).WILL_RECONNECT;
|
|
this.connectionState = WILL_RECONNECT;
|
|
this.dispatchExceptionBackoff.cancel();
|
|
if (this.dispatchExceptionBackoff._fails === 0) {
|
|
env1_14.verbose('Triggering fast reconnect');
|
|
this.dispatchExceptionBackoff.fail(function() {
|
|
});
|
|
global.setTimeout(_fun95124, 0);
|
|
} else {
|
|
this.dispatchExceptionBackoff.fail(_fun95125);
|
|
}
|
|
this.didForceClearGuildHashes = true;
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'CLEAR_CACHES',
|
|
reason: 'Socket reset during ' + action});
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'LIBDISCORE_RESET'});
|
|
global.clearTimeout(this.dispatchSuccessTimer);
|
|
this.dispatchSuccessTimer = global.setTimeout(_fun95126, 2 * env1_19);
|
|
}
|
|
|
|
function value_95128() { // fn#95128, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:18522, offset: 0x02132ef8, size: 230 bytes, params: 1, frame: 19
|
|
let value = a0;
|
|
const value2 = undefined;
|
|
const r0 = value !== value2 ? value : false;
|
|
var env0_1;
|
|
value = this.isClosed();
|
|
const binding = env1_14;
|
|
if (value) {
|
|
binding.verbose('close() called, but socket is already closed.');
|
|
if (!r0) {
|
|
this.sessionId = null;
|
|
this.token = null;
|
|
}
|
|
} else {
|
|
binding.info('Closing connection, current state is ' + this.connectionState);
|
|
env0_1 = r0 ? 4000 : value2;
|
|
this._cleanup(_fun95129);
|
|
var CLOSED = (importDefault(12503) /* metro dependency 12503: ConnectionState */).CLOSED;
|
|
this.connectionState = CLOSED;
|
|
if (!r0) {
|
|
this.sessionId = null;
|
|
this.token = null;
|
|
global.setImmediate(_fun95130);
|
|
}
|
|
}
|
|
return value2;
|
|
}
|
|
|
|
function value_95132(a0) { // fn#95132, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:19062, offset: 0x02133043, size: 326 bytes, params: 2, frame: 22
|
|
var environment;
|
|
var binding;
|
|
var verbose;
|
|
var connectionState;
|
|
let value = a1;
|
|
const value2 = a2;
|
|
const value3 = a3;
|
|
const r9 = value !== undefined ? value : '';
|
|
if (!this.isClosed()) {
|
|
if (this.isConnected()) {
|
|
value = environment.__proto__;
|
|
binding = env1_14;
|
|
value = '';
|
|
binding.verbose('Performing an expedited heartbeat ' + (r9 != null ? value === r9 ? value : 'reason: ' + r9 : value));
|
|
this.heartbeatAck = false;
|
|
this._sendHeartbeat();
|
|
if (this.expeditedHeartbeatTimeout !== null) {
|
|
global.clearTimeout(this.expeditedHeartbeatTimeout);
|
|
}
|
|
this.expeditedHeartbeatTimeout = global.setTimeout(_fun95133, a0);
|
|
} else if (!(value2 !== undefined) || value2) {
|
|
this.resetBackoff(r9, !(value3 !== undefined) || value3);
|
|
} else {
|
|
value = environment.__proto__;
|
|
binding = env1_14;
|
|
verbose = binding.verbose;
|
|
connectionState = this.connectionState;
|
|
value = '';
|
|
Reflect.apply(verbose, binding,
|
|
['Expedited heartbeat requested, but, connection state is ' + connectionState + ' and reconnectImmediately was not requested ' + (r9 != null ? value === r9 ? value : 'reason: ' + r9 : value)]);
|
|
}
|
|
}
|
|
}
|
|
|
|
function value_95134() { // fn#95134, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:19726, offset: 0x021331b6, size: 200 bytes, params: 1, frame: 20
|
|
let value = a0;
|
|
const value2 = a1;
|
|
const r5 = value !== undefined ? value : '';
|
|
let r1 = !(value2 !== undefined) || value2;
|
|
value = environment.__proto__;
|
|
const binding = env1_14;
|
|
const value3 = '';
|
|
binding.verbose('Connection has reset backoff' + (r5 != null ? value3 === r5 ? value3 : ' for reason: ' + r5 : value3));
|
|
this.gatewayBackoff.succeed();
|
|
this.iosGoingAwayEventCount = 0;
|
|
this.nextReconnectIsImmediate = true;
|
|
if (this.willReconnect()) {
|
|
this._connect();
|
|
} else {
|
|
r1 = r1 && this.connectionState !== (importDefault(12503) /* metro dependency 12503: ConnectionState */).SESSION_ESTABLISHED;
|
|
if (r1) {
|
|
this._handleClose(true, 0, r5);
|
|
}
|
|
}
|
|
}
|
|
|
|
function GatewaySocketSend(a0, a1, a2) { // fn#95062, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:1515, owner: GatewaySocket.send, offset: 0x02130883, size: 222 bytes, params: 4, frame: 21
|
|
var binding;
|
|
var verboseDangerously;
|
|
var Opcode;
|
|
var pack;
|
|
var value2;
|
|
var value3;
|
|
var isSessionEstablished;
|
|
var warn;
|
|
var HermesInternal;
|
|
var concat;
|
|
var webSocket;
|
|
var value4;
|
|
var send;
|
|
var error;
|
|
reducibleJoin2: while (true) {
|
|
if (DeveloperOptionsStore.isLoggingGatewayEvents) {
|
|
binding = env2_14;
|
|
verboseDangerously = binding.verboseDangerously;
|
|
Opcode = (require(12495) /* metro dependency 12495: GatewaySocketOpCodes */).Opcode;
|
|
Reflect.apply(verboseDangerously, binding, ['~>', a0, Opcode[a0], a1]);
|
|
break reducibleJoin2;
|
|
}
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin5: while (true) {
|
|
reduciblePort15: while (true) {
|
|
exceptionLanding14: while (true) {
|
|
binding = env2_15;
|
|
pack = binding.pack;
|
|
value2 = Reflect.apply(pack, binding, [{op: a0, d: a1}]);
|
|
if (a2) {
|
|
value3 = environment;
|
|
binding = env0_0;
|
|
isSessionEstablished = binding.isSessionEstablished;
|
|
if (Reflect.apply(isSessionEstablished, binding, [])) {
|
|
break reducibleJoin5;
|
|
}
|
|
binding = env2_14;
|
|
warn = binding.warn;
|
|
HermesInternal = global.HermesInternal;
|
|
concat = HermesInternal.concat;
|
|
Reflect.apply(warn, binding,
|
|
['Attempted to send while not being in a connected state opcode: ' + a0]);
|
|
break reduciblePort15;
|
|
}
|
|
break reducibleJoin5;
|
|
}
|
|
break reduciblePort15;
|
|
}
|
|
return undefined;
|
|
}
|
|
try {
|
|
binding = env0_0;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
try {
|
|
webSocket = binding.webSocket;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
try {
|
|
value4 = webSocket == null;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
reducibleJoin15: while (true) {
|
|
if (value4) {
|
|
break reducibleJoin15;
|
|
}
|
|
try {
|
|
binding = env0_0;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
try {
|
|
webSocket = binding.webSocket;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
try {
|
|
send = webSocket.send;
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
try {
|
|
Reflect.apply(send, webSocket, [value2]);
|
|
} catch (error) {
|
|
break exceptionLanding14;
|
|
}
|
|
break reducibleJoin15;
|
|
}
|
|
}
|
|
|
|
function _fun95071() { // fn#95071, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:4143, offset: 0x02130e41, size: 97 bytes, params: 1, frame: 16
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
const binding = env0_0;
|
|
value -= binding.connectionStartTime;
|
|
const _handleClose = binding._handleClose;
|
|
value = 'The connection timed out after ' + value + ' ms - did not receive OP_HELLO in time.';
|
|
Reflect.apply(_handleClose, binding, [false, 0, value]);
|
|
binding.setResumeUrl(null);
|
|
}
|
|
|
|
function newOrTakeoverWebSocket({gatewayURL, newCallback, onOpen, onMessage, onError, onClose}) { // fn#95072, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:4458, owner: value_95069.newOrTakeoverWebSocket, offset: 0x02130ea2, size: 637 bytes, params: 2, frame: 36
|
|
var environment;
|
|
var r17;
|
|
var r1;
|
|
var messages;
|
|
var r8;
|
|
var r9;
|
|
var open;
|
|
var ws;
|
|
var state;
|
|
var userId;
|
|
var object3;
|
|
var log;
|
|
var object4;
|
|
var identify;
|
|
var clientState;
|
|
let value = environment.__proto__.__proto__;
|
|
let binding = env2_14;
|
|
binding.enableNativeLogger(true);
|
|
const _ws = global.window._ws;
|
|
global.window._ws = null;
|
|
if (_ws != null) {
|
|
ws = _ws.ws;
|
|
state = _ws.state;
|
|
userId = state.userId;
|
|
r17 = userId != null && env2_16 != null;
|
|
r17 = r17 && userId !== env2_16;
|
|
state = _ws.state;
|
|
if (state.gateway !== gatewayURL) {
|
|
binding = env2_14;
|
|
binding.verbose('[FAST CONNECT] gatewayURL mismatch: ' + _ws.state.gateway + ' !== ' + gatewayURL);
|
|
ws.close(1000);
|
|
r1 = null;
|
|
messages = null;
|
|
r8 = null;
|
|
r9 = false;
|
|
open = false;
|
|
} else if (r17) {
|
|
binding = env2_14;
|
|
binding.log('[FAST CONNECT] refusing to adopt socket: identified user ' + userId + ' does not match switch target ' + env2_16);
|
|
ws.close(1000);
|
|
r1 = null;
|
|
messages = null;
|
|
r8 = null;
|
|
r9 = false;
|
|
open = false;
|
|
} else {
|
|
object3 = {};
|
|
state = _ws.state;
|
|
copyDataProperties(object3, state, undefined);
|
|
messages = object3.messages;
|
|
if (messages != null) {
|
|
object3.messages = object3.messages.map(function(a0) {
|
|
var r5;
|
|
var r0;
|
|
var object;
|
|
var value = a0;
|
|
if (value.data == null) {
|
|
r0 = value;
|
|
} else if (typeof value.data !== 'string') {
|
|
r0 = value;
|
|
} else {
|
|
object = {};
|
|
copyDataProperties(object, value, r5);
|
|
value = value.data.substring(0, 100);
|
|
object['data'] = value;
|
|
r0 = object;
|
|
}
|
|
return r0;
|
|
});
|
|
}
|
|
binding = env2_14;
|
|
log = binding.log;
|
|
object4 = {};
|
|
copyDataProperties(object4, object3, undefined);
|
|
messages = object3.messages;
|
|
object4['messages'] = messages?.length;
|
|
Reflect.apply(log, binding, ['[FAST CONNECT] successfully took over websocket, state:', object4]);
|
|
state = _ws.state;
|
|
open = state.open;
|
|
state = _ws.state;
|
|
identify = state.identify;
|
|
state = _ws.state;
|
|
messages = state.messages;
|
|
state = _ws.state;
|
|
clientState = state.clientState;
|
|
r1 = ws;
|
|
r8 = clientState;
|
|
r9 = identify;
|
|
}
|
|
} else {
|
|
r1 = undefined;
|
|
messages = null;
|
|
r8 = null;
|
|
r9 = false;
|
|
open = false;
|
|
}
|
|
if (r1 == null) {
|
|
value = (importDefault(12494) /* metro dependency 12494: createWebSocketAndroid */)(gatewayURL);
|
|
value.binaryType = 'arraybuffer';
|
|
r1 = value;
|
|
}
|
|
newCallback(r1);
|
|
if (open) {
|
|
onOpen(r9, r8);
|
|
}
|
|
if (messages != null) {
|
|
messages.forEach(onMessage);
|
|
}
|
|
r1.onopen = function() {
|
|
return onOpen(identify, clientState);
|
|
};
|
|
r1.onmessage = onMessage;
|
|
r1.onclose = onClose;
|
|
r1.onerror = onError;
|
|
}
|
|
|
|
function newCallback(a0) { // fn#95075, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:5499, owner: value_95069.newCallback, offset: 0x0213118c, size: 39 bytes, params: 2, frame: 11
|
|
const binding = env0_0;
|
|
binding.webSocket = a0;
|
|
binding.compressionHandler.bindWebSocket(a0);
|
|
}
|
|
|
|
function onOpen(a0) { // fn#95076, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:5569, owner: value_95069.onOpen, offset: 0x021311b3, size: 200 bytes, params: 2, frame: 23
|
|
const value = environment.__proto__.__proto__;
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'GatewaySocket.onOpen ' + a0);
|
|
const Date = global.Date;
|
|
const value3 = Date.now();
|
|
let binding = env0_0;
|
|
const value5 = value3 - binding.connectionStartTime;
|
|
const binding2 = env2_14;
|
|
binding2.info('[CONNECTED] ' + env0_1.toString() + ' in ' + value5 + ' ms');
|
|
binding.isFastConnect = a0;
|
|
binding = env0_0;
|
|
if (a0) {
|
|
binding._doFastConnectIdentify();
|
|
} else {
|
|
binding._doResumeOrIdentify();
|
|
}
|
|
}
|
|
|
|
function _fun95077(a0, a1) { // fn#95077, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:5889, offset: 0x0213127b, size: 996 bytes, params: 3, frame: 26
|
|
var r15;
|
|
var r4;
|
|
var defaultImport;
|
|
var mark;
|
|
var property;
|
|
var object;
|
|
var verboseDangerously;
|
|
var items2;
|
|
var _handleDispatch;
|
|
let Date = global.Date;
|
|
let value = Date.now();
|
|
let binding = env2_15;
|
|
const {op, s, t, d} = binding.unpack(a0);
|
|
const Opcode = (require(12495) /* metro dependency 12495: GatewaySocketOpCodes */).Opcode;
|
|
const DISPATCH = Opcode.DISPATCH;
|
|
if (op !== DISPATCH) {
|
|
defaultImport = importDefault(20) /* metro dependency 20: AppStartPerformance */;
|
|
mark = defaultImport.mark;
|
|
property = Opcode[op];
|
|
Reflect.apply(mark, defaultImport, ['🌐', 'GatewaySocket.onMessage ' + op + ' ' + property]);
|
|
r15 = property;
|
|
}
|
|
if (DeveloperOptionsStore.isLoggingGatewayEvents) {
|
|
object = [op];
|
|
if (op === Opcode.DISPATCH) {
|
|
object.push(t);
|
|
}
|
|
object.push(d);
|
|
binding = env2_14;
|
|
verboseDangerously = binding.verboseDangerously;
|
|
items2 = ['<~'];
|
|
arraySpread(items2, object, 1, r15);
|
|
apply(verboseDangerously, items2, binding, r15);
|
|
}
|
|
Date = global.Date;
|
|
const value5 = Date.now() - value;
|
|
const value6 = t === 'READY';
|
|
if (value6) {
|
|
(importDefault(14) /* metro dependency 14: TTITracker */).parseReady.set(value, value5);
|
|
} else if (t === 'READY_SUPPLEMENTAL') {
|
|
(importDefault(14) /* metro dependency 14: TTITracker */).parseReadySupplemental.set(value, value5);
|
|
} else if (value5 > 10) {
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Parse ' + t, value5);
|
|
}
|
|
value = null;
|
|
if (value != s) {
|
|
env0_0.seq = s;
|
|
}
|
|
const HELLO = Opcode.HELLO;
|
|
if (HELLO === op) {
|
|
binding = env0_0;
|
|
binding._clearHelloTimeout();
|
|
binding._handleHello(d);
|
|
} else if (Opcode.RECONNECT === op) {
|
|
env0_0._handleReconnect();
|
|
} else if (Opcode.INVALID_SESSION === op) {
|
|
env0_0._handleInvalidSession(d);
|
|
} else if (Opcode.HEARTBEAT === op) {
|
|
env0_0._handleHeartbeatReceive();
|
|
} else if (Opcode.HEARTBEAT_ACK === op) {
|
|
env0_0._handleHeartbeatAck(d);
|
|
} else if (Opcode.DISPATCH === op) {
|
|
binding = env0_0;
|
|
_handleDispatch = binding._handleDispatch;
|
|
if (value6) {
|
|
object = {compressed_byte_size: a1};
|
|
object.uncompressed_byte_size = byteSize(a0);
|
|
object.compression_algorithm = env0_0.compressionHandler.getAlgorithm();
|
|
object.packing_algorithm = env2_15.getName();
|
|
object.unpack_duration_ms = value5;
|
|
r4 = object;
|
|
} else {
|
|
r4 = value;
|
|
}
|
|
Reflect.apply(_handleDispatch, binding, [d, t, r4]);
|
|
} else {
|
|
env2_14.info('Unhandled op ' + op);
|
|
}
|
|
env0_0._sendHeartbeatIfDue();
|
|
}
|
|
|
|
function value_95069OnError() { // fn#95078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7054, owner: value_95069.onError, offset: 0x0213165f, size: 80 bytes, params: 1, frame: 16
|
|
const binding = env0_0;
|
|
binding.setResumeUrl(null);
|
|
const value = environment.__proto__.__proto__;
|
|
(importDefault(4488) /* metro dependency 4488: CrossPlatformNativeUtilsNative */).flushDNSCache();
|
|
binding._handleClose(false, 0, 'An error with the websocket occurred');
|
|
}
|
|
|
|
function value_95069OnClose({wasClean, code, reason}) { // fn#95079, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:7180, owner: value_95069.onClose, offset: 0x021316af, size: 42 bytes, params: 2, frame: 15
|
|
return env0_0._handleClose(wasClean, code, reason);
|
|
}
|
|
|
|
function _fun95092() { // fn#95092, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:9777, offset: 0x02131c3c, size: 19 bytes, params: 1, frame: 9
|
|
return env0_0._connect();
|
|
}
|
|
|
|
function _fun95097({status}) { // fn#95097, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:10915, offset: 0x02131f42, size: 166 bytes, params: 2, frame: 17
|
|
var binding;
|
|
var value2;
|
|
if (status === 401) {
|
|
binding = env0_0;
|
|
value2 = environment.__proto__.__proto__;
|
|
binding.connectionState = (importDefault(12503) /* metro dependency 12503: ConnectionState */).CLOSED;
|
|
env2_14.warn('[WS CLOSED] because of manual authentication failure, marking as closed.');
|
|
binding._reset(importDefault, 4004, 'invalid token manually detected');
|
|
}
|
|
const defaultImport = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
const track = defaultImport.track;
|
|
const IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED = AnalyticEvents.IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED;
|
|
Reflect.apply(track, defaultImport, [IOS_INVALID_TOKEN_WORKAROUND_TRIGGERED, {api_status_code: status}]);
|
|
}
|
|
|
|
function _fun95102() { // fn#95102, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:12101, offset: 0x021321cb, size: 77 bytes, params: 1, frame: 14
|
|
const binding = env0_0;
|
|
binding.initialHeartbeatTimeout = null;
|
|
binding.heartbeatAck = true;
|
|
binding.heartbeater = global.setInterval(binding._doHeartbeatInterval.bind(binding), heartbeatInterval);
|
|
binding._doHeartbeatInterval();
|
|
}
|
|
|
|
function _fun95126() { // fn#95126, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:18249, offset: 0x02132e7e, size: 25 bytes, params: 1, frame: 9
|
|
return env0_0.dispatchExceptionBackoff.succeed();
|
|
}
|
|
|
|
function _fun95129(a0) { // fn#95129, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:18774, offset: 0x02132fde, size: 23 bytes, params: 2, frame: 11
|
|
return a0.close(env0_1);
|
|
}
|
|
|
|
function _fun95130() { // fn#95130, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:18881, offset: 0x02132ff5, size: 38 bytes, params: 1, frame: 15
|
|
env0_0._reset(true, 1000, 'Disconnect requested by user');
|
|
}
|
|
|
|
function _fun95133() { // fn#95133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12681:19393, offset: 0x02133189, size: 45 bytes, params: 1, frame: 10
|
|
const binding = env0_0;
|
|
binding.expeditedHeartbeatTimeout = null;
|
|
if (binding.heartbeatAck === false) {
|
|
env0_0._handleHeartbeatTimeout();
|
|
}
|
|
}
|
|
|