decord/alpha/source/modules/gateway/GatewaySocketSingleton.tsx

94 lines
3.5 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 14265
// Function ID: 14266
// Name: GatewaySocketSingleton
2026-10-13 12:43:34 +00:00
// Dependencies: [14266, 502, 3, 14267, 14304, 14307, 6071, 1265, 9704, 1382, 4731, 1481, 584, 2]
2026-07-23 10:11:24 +00:00
2026-10-13 12:43:34 +00:00
// Module 14265 (GatewaySocketSingleton)
import LoggerDefault from "Logger" /* 3 */;
2026-10-03 08:58:59 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
2026-10-10 08:08:14 +00:00
import DiscordNativeDefault from "DiscordNative" /* 4731 */;
import DiscordAppStateDefault from "DiscordAppState" /* 6071 */;
2026-10-12 06:59:38 +00:00
import RequestGatewaySocketAll from "RequestGatewaySocket" /* 9704 */;
2026-10-13 12:43:34 +00:00
import GatewaySocketDefault from "GatewaySocket" /* 14267 */;
import LocalPresenceStateManagerDefault from "LocalPresenceStateManager" /* 14304 */;
import LocalVoiceStateManagerDefault from "LocalVoiceStateManager" /* 14307 */;
import MultiAccountSwitchStore from "MultiAccountSwitchStore" /* 14266 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-09 10:00:15 +00:00
import PlatformUtils from "PlatformUtils" /* 1382 */;
import NetworkUtils_mod from "NetworkUtils" /* 1481 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-20 16:05:17 +00:00
let closure_5 = new LoggerDefault("ConnectionStore");
2026-10-03 08:58:59 +00:00
new LoggerDefault("ConnectionStore");
const socket = new GatewaySocketDefault();
const tmp3 = new LocalPresenceStateManagerDefault(socket);
const initialState = tmp3;
socket.handleIdentify = () => {
2026-10-03 08:58:59 +00:00
let id;
let obj4;
let obj5;
const token = AuthenticationStore.getToken();
2026-10-03 08:58:59 +00:00
const obj2 = { hasToken: null != token };
closure_5.verbose("handleIdentify called", obj2);
2026-07-20 16:05:17 +00:00
if (null == token) {
return null;
} else {
2026-10-03 08:58:59 +00:00
let obj7;
const obj8 = DiscordAppStateDefault;
const state = obj8.getState();
2026-07-29 08:29:29 +00:00
const installationForTracking = obj.getInstallationForTracking();
2026-10-03 08:58:59 +00:00
const obj3 = { token, userId: id, properties: obj4, presence: initialState.getInitialState() };
id = obj.getId();
const tmp12 = importDefault;
if (id == null) {
id = MultiAccountSwitchStore.getTargetUserId();
}
2026-10-03 08:58:59 +00:00
obj4 = { client_app_state: state, is_fast_connect: false, gateway_connect_reasons: obj5.describeConnectionReasons() };
2026-10-09 10:00:15 +00:00
const tmp12Result = tmp12(1265);
2026-10-03 08:58:59 +00:00
const merged = Object.assign(tmp12Result.getSuperProperties());
obj5 = RequestGatewaySocketAll;
2026-07-20 16:05:17 +00:00
if (null != installationForTracking) {
2026-10-03 08:58:59 +00:00
obj7 = { installation_id: installationForTracking };
const obj6 = { installation_id: installationForTracking };
2026-07-20 16:05:17 +00:00
} else {
obj7 = {};
2026-07-20 16:05:17 +00:00
}
const merged1 = Object.assign(obj7);
return obj3;
2026-07-20 16:05:17 +00:00
}
};
2026-10-03 08:58:59 +00:00
const tmp4 = new LocalVoiceStateManagerDefault(socket);
if (PlatformUtils.isDesktop()) {
const powerMonitor = DiscordNativeDefault.powerMonitor;
2026-07-20 16:05:17 +00:00
powerMonitor.on("resume", () => {
2026-07-29 08:29:29 +00:00
obj.expeditedHeartbeat(5000, "power monitor resumed");
2026-07-20 16:05:17 +00:00
});
}
let NetworkUtils = NetworkUtils_mod;
NetworkUtils.addOfflineCallback(() => {
2026-07-29 08:29:29 +00:00
obj.networkStateChange(15000, "network detected offline.", false);
2026-07-20 16:05:17 +00:00
});
2026-10-03 08:58:59 +00:00
NetworkUtils = NetworkUtils_mod;
NetworkUtils.addOnlineCallback(() => {
2026-07-29 08:29:29 +00:00
obj.networkStateChange(5000, "network detected online.");
2026-07-20 16:05:17 +00:00
});
socket.on("disconnect", (arg0) => {
2026-10-03 08:58:59 +00:00
let code;
let reason;
2026-07-20 16:05:17 +00:00
({ code, reason } = arg0);
2026-10-03 08:58:59 +00:00
const obj = DispatcherDefault;
obj.dispatch({ type: "CONNECTION_CLOSED", code, reason });
2026-07-20 16:05:17 +00:00
});
socket.on("close", (arg0) => {
2026-10-03 08:58:59 +00:00
let code;
let reason;
2026-07-20 16:05:17 +00:00
({ code, reason } = arg0);
2026-10-03 08:58:59 +00:00
const obj = DispatcherDefault;
obj.dispatch({ type: "CONNECTION_INTERRUPTED", code, reason });
2026-07-20 16:05:17 +00:00
});
const result = size.fileFinishedImporting("modules/gateway/GatewaySocketSingleton.tsx");
2026-07-20 16:05:17 +00:00
export { socket };
2026-07-29 08:29:29 +00:00
export const localPresenceState = tmp3;
2026-10-03 08:58:59 +00:00
export const localVoiceState = tmp4;