TP-89230 | current call state
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user