mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
refactor(server/source-handling): Altered how we handle source
These changes are made in case source is not guranteed to remain the same Due to how JS should operate, this shouldn't be an issue but this just ensures that
This commit is contained in:
1 parent
acb8e056c3
commit
1aa6a383ab
12 files changed
+222
-140
No files matched your search
+17
-11
@@ -3,7 +3,8 @@ import events from '../utils/events';
|
||||
import {
|
||||
getIdentifierByPhoneNumber,
|
||||
usePhoneNumber,
|
||||
useIdentifier,
|
||||
getIdentifier,
|
||||
getSource,
|
||||
} from './functions';
|
||||
import { XPlayer } from 'esx.js/@types/server';
|
||||
import { ICall } from '../../phone/src/common/typings/call';
|
||||
@@ -66,7 +67,7 @@ let calls: Map<string, ICall> = new Map();
|
||||
onNet(
|
||||
events.PHONE_INITIALIZE_CALL,
|
||||
async (phoneNumber: string, timestamp: number) => {
|
||||
const _source = (global as any).source;
|
||||
const _source = getSource();
|
||||
|
||||
const callIdentifier = uuidv4();
|
||||
|
||||
@@ -115,9 +116,8 @@ onNet(
|
||||
);
|
||||
|
||||
onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const pSource = (global as any).source;
|
||||
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
const channelId = pSource;
|
||||
|
||||
@@ -141,15 +141,17 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
true
|
||||
);
|
||||
} catch (e) {
|
||||
callLogger.error('Accepting Call Error', e.message);
|
||||
callLogger.error('Accepting Call Error', e.message, {
|
||||
source: pSource,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.PHONE_CALL_REJECTED,
|
||||
async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const pSource = (global as any).source;
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
|
||||
await updateCall(currentCall, false, timestamp);
|
||||
@@ -159,7 +161,9 @@ onNet(
|
||||
// player who is calling
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
||||
} catch (e) {
|
||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`);
|
||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -167,8 +171,8 @@ onNet(
|
||||
onNet(
|
||||
events.PHONE_END_CALL,
|
||||
async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const pSource = (global as any).source;
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
|
||||
const endTime = timestamp / 1000;
|
||||
@@ -182,14 +186,16 @@ onNet(
|
||||
|
||||
calls.delete(transmitterNumber);
|
||||
} catch (e) {
|
||||
callLogger.error(`Error ending Phone Call, ${e.message}`);
|
||||
callLogger.error(`Error ending Phone Call, ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
||||
const _source = (global as any).source;
|
||||
const identifier = await useIdentifier();
|
||||
const _source = getSource();
|
||||
const identifier = await getIdentifier(_source);
|
||||
const phoneNumber = await usePhoneNumber(identifier);
|
||||
|
||||
const calls = await fetchCalls(phoneNumber);
|
||||
|
||||
Reference in new issue
Block a user