TP-89230 | current call state

This commit is contained in:
varnit goyal
2024-11-27 09:25:23 +05:30
parent c3eeedce5d
commit 8c2283e075
2 changed files with 15 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
import IAdapter from "@universal-call-sdk/common/lib/Interfaces/IAdapter.ts";
import GenericObject from "@universal-call-sdk/common/lib/types/GenericObject.ts";
import {AmeyoInitializationOptions, RequestKeys, SipAccountInfo, StateType} from "./types.ts";
import {AmeyoInitializationOptions, CALL_STATES, RequestKeys, SipAccountInfo, StateType} from "./types.ts";
import MessagingType from "../types/MessagingType.ts";
import {
ameyoHangupUser,
@@ -32,6 +32,7 @@ class AmeyoAdapter implements IAdapter {
onAgentAvailabilityChange: (isAgentAvailable: boolean) => void
onForcedLogout: () => void
};
private currentCallState: string;
private eventListenerUrl: string;
private baseUrl: string;
private sessionId: string;
@@ -143,6 +144,7 @@ class AmeyoAdapter implements IAdapter {
console.log('campaign selected', payload?.data?.response);
autoSelectExtension(this.sessionId, this.userName.toLowerCase());
this.callbacks.onAdapterReady();
this.currentCallState = CALL_STATES.IDLE;
this.callbacks.onAgentAvailabilityChange(true);
window.postMessage({type: 'onAmeyoAvailabiltyChange', data: false},);
}
@@ -160,14 +162,17 @@ class AmeyoAdapter implements IAdapter {
}
if (data?.type === MessagingType.ON_AMEYO_CALL_INCOMING) {
this.callbacks.onCallIncoming(data?.data);
this.currentCallState = CALL_STATES.CALL_INCOMING;
this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data}
}
if (data?.type === MessagingType.ON_AMEYO_CALL_ACCEPTED) {
this.callbacks.onCallConnected(data?.data);
this.currentCallState = CALL_STATES.CALL_CONNECTED;
this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data}
}
if (data?.type === MessagingType.ON_AMEYO_CALL_DISCONNECTED) {
this.callbacks.onCallDisconnected(data?.data);
this.currentCallState = CALL_STATES.CALL_DISCONNECTED;
ameyoHangupUser(this.sessionId, this.currentCallMetadata?.userCRTObjectId);
this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data}
}
@@ -250,7 +255,7 @@ class AmeyoAdapter implements IAdapter {
}
getLatestCallState() {
return this.currentCallMetadata;
return this.currentCallState;
}
private _appendTags: () => void = () => {

View File

@@ -55,3 +55,11 @@ export type SipAccountInfo = {
domain: string,
password: string
}
export enum CALL_STATES {
CALL_INCOMING = 'CALL_INCOMING',
CALL_CONNECTED = 'CALL_CONNECTED',
CALL_DISCONNECTED = 'CALL_DISCONNECTED',
IDLE = 'IDLE',
}