NTP-21033 | erreronous and availability fix

This commit is contained in:
varnit goyal
2025-01-06 15:19:34 +05:30
parent d20f0dc45f
commit ae612e38ec
5 changed files with 19 additions and 22 deletions

View File

@@ -12,6 +12,7 @@ export enum MessagingType {
ON_AMEYO_AGENT_ON_BREAK = 'onAmeyoAgentOnBreak',
ON_AMEYO_FORCED_LOGOUT = 'onAmeyoForcedLogout',
ON_AMEYO_CALL_TRANSFER = 'onAmeyoCallTransfer',
ON_AMEYO_AVAILABILITY_CHANGE = 'onAmeyoAvailabilityChange'
}
@@ -116,16 +117,16 @@ function extractUserCallModelUpdatedPush(rawResponse) {
}
}
if (jsonData?.pushType === pushResponseTypes.UserCCRuntimeUpdatedPush) {
console.log('payload for user runtime update push');
const payload = jsonData?.data;
//handle ameyo erroronous condition
if (payload?.isOnBreak) {
window.postMessage({
type: MessagingType.ON_AMEYO_AGENT_ON_BREAK,
data: {
reason: payload,
}
});
}
window.postMessage({
type: messagingType.ON_AMEYO_AVAILABILITY_CHANGE,
data:{
isOnBreak: payload?.isOnBreak,
reason: payload?.statusDescription
}
})
}
if (jsonData?.pushType == pushResponseTypes.UserLoggedOffPush) {
const payload = jsonData?.data;

View File

@@ -39,7 +39,7 @@ class AmeyoAdapter implements IAdapter {
onCallDisconnected: (data: StateType) => void;
onCallIncoming: (data: StateType) => void,
onAdapterReady: () => void,
onAgentAvailabilityChange: (isAgentAvailable: boolean) => void
onAgentAvailabilityChange: (isAgentAvailable: boolean, reason: string) => void
onForcedLogout: () => void,
onLoginFailed: (err: GenericObject)=>void
onAgentsForCallTransfer: (data: GenericObject) => void
@@ -186,9 +186,6 @@ class AmeyoAdapter implements IAdapter {
}
if (payload?.data?.requestKey === RequestKeys.AMEYO_AVAILABLE) {
setAutoStatus(this.sessionId);
this.isAgentAvailable = true;
window.postMessage({type: 'onAmeyoAvailabiltyChange', data: true});
this.callbacks.onAgentAvailabilityChange(true)
}
if (payload?.data?.requestKey === RequestKeys.OMNIQUEUE_SERVICE) {
@@ -198,13 +195,9 @@ class AmeyoAdapter implements IAdapter {
autoSelectExtension(this.sessionId, this.userName.toLowerCase());
this.callbacks.onAdapterReady();
this.currentCallState = CALL_STATES.IDLE;
this.callbacks.onAgentAvailabilityChange(true);
window.postMessage({type: 'onAmeyoAvailabiltyChange', data: false},);
}
if (payload?.data?.requestKey === RequestKeys.AMEYO_ON_BREAK) {
setAutoStatus(this.sessionId);
this.isAgentAvailable = false;
this.callbacks.onAgentAvailabilityChange(false);
window.postMessage({type: 'onAmeyoAvailabiltyChange', data: false},);
}
if (payload?.data?.requestKey === RequestKeys.GET_AGENTS_FOR_CALL_TRANSFER) {
@@ -243,9 +236,11 @@ class AmeyoAdapter implements IAdapter {
audioElement?.play();
}
if (data?.type === MessagingType.ON_AMEYO_AGENT_ON_BREAK) {
this.isAgentAvailable = false;
this.callbacks.onAgentAvailabilityChange(false);
if (data?.type === MessagingType.ON_AMEYO_AVAILABILITY_CHANGE) {
this.isAgentAvailable = !data?.data?.isOnBreak;
this.callbacks.onAgentAvailabilityChange(this.isAgentAvailable, data?.data?.reason || '');
window.postMessage({type: 'onAmeyoAvailabiltyChange', data: this.isAgentAvailable,});
}
if (data?.type === MessagingType.ON_AMEYO_FORCED_LOGOUT) {
this.callbacks.onForcedLogout()
@@ -275,7 +270,7 @@ class AmeyoAdapter implements IAdapter {
this.callbacks.onAdapterReady = callback;
}
registerOnAgentAvailabilityChange(callback: (isAgentAvailable: boolean) => void) {
registerOnAgentAvailabilityChange(callback: (isAgentAvailable: boolean, reason: string) => void) {
console.log('registerOnAgentAvailabilityChange');
this.callbacks.onAgentAvailabilityChange = callback;
}

View File

@@ -7,6 +7,7 @@
ON_AMEYO_AGENT_ON_BREAK = 'onAmeyoAgentOnBreak',
ON_AMEYO_FORCED_LOGOUT = 'onAmeyoForcedLogout',
ON_AMEYO_CALL_TRANSFER = 'onAmeyoCallTransfer',
ON_AMEYO_AVAILABILITY_CHANGE= 'onAmeyoAvailablityChange'
}

View File

@@ -8,7 +8,7 @@ class IAdapter {
registerOnCallConnected(callback: (callState: GenericObject)=>void) {callback({})}
registerOnCallDisconnected(callback: (callState: GenericObject)=>void) {callback({})}
registerOnAdapterReady(callback: ()=> void) {callback()}
registerOnAgentAvailabilityChange(callback: (isAgentAvailable: boolean) => void) {callback(false)}
registerOnAgentAvailabilityChange(callback: (isAgentAvailable: boolean, reason: string) => void) {callback(false, '')}
registerOnForcedLogoutListener(callback:()=>void) {callback()}
registerOnLoginFailedListener(callback:()=>void) {callback()}
registerOnAgentsForCallTransfer(callback: (data : GenericObject) => void) {callback({})}

View File

@@ -113,7 +113,7 @@ function UseCallSdk({AdapterClass, adapterOptions, metricsConfig, clickStreamCon
}
function registerOnAgentAvailabilityChange(callback : (isAgentAvailable: boolean) => void) {
function registerOnAgentAvailabilityChange(callback : (isAgentAvailable: boolean, reason: string) => void) {
adapter.registerOnAgentAvailabilityChange(callback);
}