50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
// Metro module 13546 (f13547).
|
|
import { RPC_LOCAL_SCOPE } from "../../Constants";
|
|
import { AnalyticEvents, Endpoints, RPCCommands } from "../../../../Constants";
|
|
import { HTTP } from "../../../../_bundle/sendRequest";
|
|
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
|
|
const r22 = {};
|
|
r22[RPCCommands.GET_NETWORKING_CONFIG] = {
|
|
scope: RPC_LOCAL_SCOPE,
|
|
handler: () => Promise.all([HTTP.get({
|
|
url: location.protocol + window.GLOBAL_ENV.NETWORKING_ENDPOINT,
|
|
retries: 3,
|
|
rejectWithError: false
|
|
}).then((result) => result.body.address), HTTP.post({
|
|
url: Endpoints.NETWORKING_TOKEN,
|
|
retries: 3,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
}).then((result) => result.body.token)]).then((result) => {
|
|
const [address, token] = result;
|
|
return {
|
|
address,
|
|
token
|
|
};
|
|
})
|
|
};
|
|
r22[RPCCommands.NETWORKING_SYSTEM_METRICS] = {
|
|
scope: RPC_LOCAL_SCOPE,
|
|
handler: ({ socket, args }) => {
|
|
args.application_id = socket.application.id;
|
|
AnalyticsUtils.track(AnalyticEvents.NETWORKING_SYSTEM_METRICS, args);
|
|
}
|
|
};
|
|
r22[RPCCommands.NETWORKING_PEER_METRICS] = {
|
|
scope: RPC_LOCAL_SCOPE,
|
|
handler: ({ socket, args }) => {
|
|
args.application_id = socket.application.id;
|
|
AnalyticsUtils.track(AnalyticEvents.NETWORKING_PEER_METRICS, args);
|
|
}
|
|
};
|
|
r22[RPCCommands.NETWORKING_CREATE_TOKEN] = {
|
|
scope: RPC_LOCAL_SCOPE,
|
|
handler: () => HTTP.post({
|
|
url: Endpoints.NETWORKING_TOKEN,
|
|
retries: 1,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
}).then((result) => result.body)
|
|
};
|
|
export default r22;
|