Merge pull request #13 from navi-commons/TP-89230/current-call-state

TP-89230 | current call state
This commit is contained in:
Varnit Goyal
2024-11-27 10:28:30 +05:30
committed by GitHub
8 changed files with 44 additions and 6 deletions

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.0.61 (2024-11-27)
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo
## 1.0.60 (2024-11-25)
**Note:** Version bump only for package @universal-call-sdk/adapter-ameyo

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;
@@ -51,6 +52,7 @@ class AmeyoAdapter implements IAdapter {
document.body.appendChild(script);
this.baseUrl = options.baseUrl;
this.eventListenerUrl = options.eventListenerUrl;
this.currentCallState = CALL_STATES.IDLE;
this.callbacks = {
onCallIncoming: () => {
},
@@ -143,6 +145,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 +163,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 +256,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',
}

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/adapter-ameyo",
"version": "1.0.60",
"version": "1.0.61",
"type": "module",
"scripts": {
"dev": "vite",
@@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@universal-call-sdk/common": "^1.0.15"
"@universal-call-sdk/common": "^1.0.16"
},
"devDependencies": {
"@eslint/js": "^9.11.1",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.0.16 (2024-11-27)
**Note:** Version bump only for package @universal-call-sdk/common
## 1.0.15 (2024-11-25)
**Note:** Version bump only for package @universal-call-sdk/common

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/common",
"version": "1.0.15",
"version": "1.0.16",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.0.21 (2024-11-27)
**Note:** Version bump only for package @universal-call-sdk/core
## 1.0.20 (2024-11-25)
**Note:** Version bump only for package @universal-call-sdk/core

View File

@@ -1,6 +1,6 @@
{
"name": "@universal-call-sdk/core",
"version": "1.0.20",
"version": "1.0.21",
"type": "module",
"scripts": {
"dev": "vite",