@webex/calling 3.0.0-next.4 → 3.0.0-next.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/CHANGELOG.md +1403 -1403
  2. package/README.md +74 -74
  3. package/dist/CallHistory/CallHistory.js +201 -0
  4. package/dist/CallHistory/CallHistory.js.map +1 -0
  5. package/dist/CallHistory/CallHistory.test.js +142 -0
  6. package/dist/CallHistory/CallHistory.test.js.map +1 -0
  7. package/dist/CallHistory/callHistoryFixtures.js +366 -0
  8. package/dist/CallHistory/callHistoryFixtures.js.map +1 -0
  9. package/dist/CallHistory/constants.js +17 -0
  10. package/dist/CallHistory/constants.js.map +1 -0
  11. package/dist/CallHistory/types.js +7 -0
  12. package/dist/CallHistory/types.js.map +1 -0
  13. package/dist/CallSettings/CallSettings.js +279 -0
  14. package/dist/CallSettings/CallSettings.js.map +1 -0
  15. package/dist/CallSettings/CallSettings.test.js +122 -0
  16. package/dist/CallSettings/CallSettings.test.js.map +1 -0
  17. package/dist/CallSettings/UcmBackendConnector.js +216 -0
  18. package/dist/CallSettings/UcmBackendConnector.js.map +1 -0
  19. package/dist/CallSettings/UcmBackendConnector.test.js +259 -0
  20. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -0
  21. package/dist/CallSettings/WxCallBackendConnector.js +547 -0
  22. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -0
  23. package/dist/CallSettings/WxCallBackendConnector.test.js +802 -0
  24. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -0
  25. package/dist/CallSettings/constants.js +19 -0
  26. package/dist/CallSettings/constants.js.map +1 -0
  27. package/dist/CallSettings/testFixtures.js +68 -0
  28. package/dist/CallSettings/testFixtures.js.map +1 -0
  29. package/dist/CallSettings/types.js +7 -0
  30. package/dist/CallSettings/types.js.map +1 -0
  31. package/dist/CallingClient/CallingClient.js +631 -0
  32. package/dist/CallingClient/CallingClient.js.map +1 -0
  33. package/dist/CallingClient/CallingClient.test.js +992 -0
  34. package/dist/CallingClient/CallingClient.test.js.map +1 -0
  35. package/dist/CallingClient/callRecordFixtures.js +101 -0
  36. package/dist/CallingClient/callRecordFixtures.js.map +1 -0
  37. package/dist/CallingClient/calling/CallerId/index.js +267 -0
  38. package/dist/CallingClient/calling/CallerId/index.js.map +1 -0
  39. package/dist/CallingClient/calling/CallerId/index.test.js +274 -0
  40. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -0
  41. package/dist/CallingClient/calling/CallerId/types.js +7 -0
  42. package/dist/CallingClient/calling/CallerId/types.js.map +1 -0
  43. package/dist/CallingClient/calling/call.js +3055 -0
  44. package/dist/CallingClient/calling/call.js.map +1 -0
  45. package/dist/CallingClient/calling/call.test.js +2858 -0
  46. package/dist/CallingClient/calling/call.test.js.map +1 -0
  47. package/dist/CallingClient/calling/callManager.js +432 -0
  48. package/dist/CallingClient/calling/callManager.js.map +1 -0
  49. package/dist/CallingClient/calling/callManager.test.js +683 -0
  50. package/dist/CallingClient/calling/callManager.test.js.map +1 -0
  51. package/dist/CallingClient/calling/index.js +30 -0
  52. package/dist/CallingClient/calling/index.js.map +1 -0
  53. package/dist/CallingClient/calling/types.js +69 -0
  54. package/dist/CallingClient/calling/types.js.map +1 -0
  55. package/dist/CallingClient/callingClientFixtures.js +143 -0
  56. package/dist/CallingClient/callingClientFixtures.js.map +1 -0
  57. package/dist/CallingClient/constants.js +134 -0
  58. package/dist/CallingClient/constants.js.map +1 -0
  59. package/dist/CallingClient/line/index.js +314 -0
  60. package/dist/CallingClient/line/index.js.map +1 -0
  61. package/dist/CallingClient/line/line.test.js +270 -0
  62. package/dist/CallingClient/line/line.test.js.map +1 -0
  63. package/dist/CallingClient/line/types.js +21 -0
  64. package/dist/CallingClient/line/types.js.map +1 -0
  65. package/dist/CallingClient/registration/index.js +19 -0
  66. package/dist/CallingClient/registration/index.js.map +1 -0
  67. package/dist/CallingClient/registration/register.js +1286 -0
  68. package/dist/CallingClient/registration/register.js.map +1 -0
  69. package/dist/CallingClient/registration/register.test.js +839 -0
  70. package/dist/CallingClient/registration/register.test.js.map +1 -0
  71. package/dist/CallingClient/registration/registerFixtures.js +36 -0
  72. package/dist/CallingClient/registration/registerFixtures.js.map +1 -0
  73. package/dist/CallingClient/registration/types.js +7 -0
  74. package/dist/CallingClient/registration/types.js.map +1 -0
  75. package/dist/CallingClient/types.js +7 -0
  76. package/dist/CallingClient/types.js.map +1 -0
  77. package/dist/Contacts/ContactsClient.js +1156 -0
  78. package/dist/Contacts/ContactsClient.js.map +1 -0
  79. package/dist/Contacts/ContactsClient.test.js +725 -0
  80. package/dist/Contacts/ContactsClient.test.js.map +1 -0
  81. package/dist/Contacts/constants.js +28 -0
  82. package/dist/Contacts/constants.js.map +1 -0
  83. package/dist/Contacts/contactFixtures.js +314 -0
  84. package/dist/Contacts/contactFixtures.js.map +1 -0
  85. package/dist/Contacts/types.js +43 -0
  86. package/dist/Contacts/types.js.map +1 -0
  87. package/dist/Errors/catalog/CallError.js +92 -0
  88. package/dist/Errors/catalog/CallError.js.map +1 -0
  89. package/dist/Errors/catalog/CallingDeviceError.js +86 -0
  90. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -0
  91. package/dist/Errors/catalog/ExtendedError.js +44 -0
  92. package/dist/Errors/catalog/ExtendedError.js.map +1 -0
  93. package/dist/Errors/catalog/LineError.js +88 -0
  94. package/dist/Errors/catalog/LineError.js.map +1 -0
  95. package/dist/Errors/index.js +28 -0
  96. package/dist/Errors/index.js.map +1 -0
  97. package/dist/Errors/types.js +57 -0
  98. package/dist/Errors/types.js.map +1 -0
  99. package/dist/Events/impl/index.js +81 -0
  100. package/dist/Events/impl/index.js.map +1 -0
  101. package/dist/Events/types.js +103 -0
  102. package/dist/Events/types.js.map +1 -0
  103. package/dist/Logger/index.js +220 -0
  104. package/dist/Logger/index.js.map +1 -0
  105. package/dist/Logger/index.test.js +62 -0
  106. package/dist/Logger/index.test.js.map +1 -0
  107. package/dist/Logger/types.js +34 -0
  108. package/dist/Logger/types.js.map +1 -0
  109. package/dist/Metrics/index.js +327 -0
  110. package/dist/Metrics/index.js.map +1 -0
  111. package/dist/Metrics/index.test.js +291 -0
  112. package/dist/Metrics/index.test.js.map +1 -0
  113. package/dist/Metrics/types.js +45 -0
  114. package/dist/Metrics/types.js.map +1 -0
  115. package/dist/SDKConnector/index.js +104 -0
  116. package/dist/SDKConnector/index.js.map +1 -0
  117. package/dist/SDKConnector/index.test.js +9 -0
  118. package/dist/SDKConnector/index.test.js.map +1 -0
  119. package/dist/SDKConnector/types.js +7 -0
  120. package/dist/SDKConnector/types.js.map +1 -0
  121. package/dist/SDKConnector/utils.js +39 -0
  122. package/dist/SDKConnector/utils.js.map +1 -0
  123. package/dist/SDKConnector/utils.test.js +9 -0
  124. package/dist/SDKConnector/utils.test.js.map +1 -0
  125. package/dist/Voicemail/BroadworksBackendConnector.js +641 -0
  126. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -0
  127. package/dist/Voicemail/BroadworksBackendConnector.test.js +733 -0
  128. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -0
  129. package/dist/Voicemail/UcmBackendConnector.js +574 -0
  130. package/dist/Voicemail/UcmBackendConnector.js.map +1 -0
  131. package/dist/Voicemail/UcmBackendConnector.test.js +629 -0
  132. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -0
  133. package/dist/Voicemail/Voicemail.js +380 -0
  134. package/dist/Voicemail/Voicemail.js.map +1 -0
  135. package/dist/Voicemail/Voicemail.test.js +226 -0
  136. package/dist/Voicemail/Voicemail.test.js.map +1 -0
  137. package/dist/Voicemail/WxCallBackendConnector.js +547 -0
  138. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -0
  139. package/dist/Voicemail/WxCallBackendConnector.test.js +942 -0
  140. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -0
  141. package/dist/Voicemail/constants.js +37 -0
  142. package/dist/Voicemail/constants.js.map +1 -0
  143. package/dist/Voicemail/types.js +7 -0
  144. package/dist/Voicemail/types.js.map +1 -0
  145. package/dist/Voicemail/voicemailFixture.js +524 -0
  146. package/dist/Voicemail/voicemailFixture.js.map +1 -0
  147. package/dist/api.js +157 -0
  148. package/dist/api.js.map +1 -0
  149. package/dist/common/Utils.js +1257 -0
  150. package/dist/common/Utils.js.map +1 -0
  151. package/dist/common/Utils.test.js +1227 -0
  152. package/dist/common/Utils.test.js.map +1 -0
  153. package/dist/common/constants.js +49 -0
  154. package/dist/common/constants.js.map +1 -0
  155. package/dist/common/index.js +19 -0
  156. package/dist/common/index.js.map +1 -0
  157. package/dist/common/testUtil.js +959 -0
  158. package/dist/common/testUtil.js.map +1 -0
  159. package/dist/common/types.js +66 -0
  160. package/dist/common/types.js.map +1 -0
  161. package/dist/index.js +309 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/module/CallHistory/CallHistory.js +83 -81
  164. package/dist/module/CallHistory/callHistoryFixtures.js +366 -307
  165. package/dist/module/CallHistory/constants.js +9 -9
  166. package/dist/module/CallHistory/types.js +1 -1
  167. package/dist/module/CallSettings/CallSettings.js +65 -65
  168. package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
  169. package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
  170. package/dist/module/CallSettings/constants.js +11 -11
  171. package/dist/module/CallSettings/testFixtures.js +62 -62
  172. package/dist/module/CallSettings/types.js +1 -1
  173. package/dist/module/CallingClient/CallingClient.js +265 -248
  174. package/dist/module/CallingClient/callRecordFixtures.js +93 -93
  175. package/dist/module/CallingClient/calling/CallerId/index.js +149 -169
  176. package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
  177. package/dist/module/CallingClient/calling/call.js +1701 -1658
  178. package/dist/module/CallingClient/calling/callManager.js +278 -284
  179. package/dist/module/CallingClient/calling/index.js +2 -2
  180. package/dist/module/CallingClient/calling/types.js +53 -53
  181. package/dist/module/CallingClient/callingClientFixtures.js +156 -38
  182. package/dist/module/CallingClient/constants.js +126 -122
  183. package/dist/module/CallingClient/line/index.js +155 -158
  184. package/dist/module/CallingClient/line/types.js +10 -15
  185. package/dist/module/CallingClient/registration/index.js +1 -1
  186. package/dist/module/CallingClient/registration/register.js +515 -507
  187. package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
  188. package/dist/module/CallingClient/registration/types.js +1 -1
  189. package/dist/module/CallingClient/types.js +1 -1
  190. package/dist/module/Contacts/ContactsClient.js +487 -484
  191. package/dist/module/Contacts/constants.js +20 -20
  192. package/dist/module/Contacts/contactFixtures.js +284 -284
  193. package/dist/module/Contacts/types.js +10 -10
  194. package/dist/module/Errors/catalog/CallError.js +26 -26
  195. package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
  196. package/dist/module/Errors/catalog/ExtendedError.js +10 -10
  197. package/dist/module/Errors/catalog/LineError.js +24 -24
  198. package/dist/module/Errors/index.js +3 -2
  199. package/dist/module/Errors/types.js +48 -48
  200. package/dist/module/Events/impl/index.js +19 -19
  201. package/dist/module/Events/types.js +85 -83
  202. package/dist/module/Logger/index.js +114 -114
  203. package/dist/module/Logger/types.js +25 -25
  204. package/dist/module/Metrics/index.js +232 -232
  205. package/dist/module/Metrics/types.js +37 -37
  206. package/dist/module/SDKConnector/index.js +39 -39
  207. package/dist/module/SDKConnector/types.js +1 -1
  208. package/dist/module/SDKConnector/utils.js +12 -12
  209. package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
  210. package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
  211. package/dist/module/Voicemail/Voicemail.js +110 -110
  212. package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
  213. package/dist/module/Voicemail/constants.js +29 -29
  214. package/dist/module/Voicemail/types.js +1 -1
  215. package/dist/module/Voicemail/voicemailFixture.js +510 -510
  216. package/dist/module/api.js +7 -6
  217. package/dist/module/common/Utils.js +797 -802
  218. package/dist/module/common/constants.js +41 -41
  219. package/dist/module/common/index.js +1 -1
  220. package/dist/module/common/testUtil.js +939 -938
  221. package/dist/module/common/types.js +58 -57
  222. package/dist/module/index.js +17 -8
  223. package/dist/types/CallHistory/CallHistory.d.ts +18 -17
  224. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  225. package/dist/types/CallHistory/callHistoryFixtures.d.ts +95 -94
  226. package/dist/types/CallHistory/callHistoryFixtures.d.ts.map +1 -1
  227. package/dist/types/CallHistory/constants.d.ts +9 -9
  228. package/dist/types/CallHistory/types.d.ts +18 -18
  229. package/dist/types/CallSettings/CallSettings.d.ts +19 -19
  230. package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
  231. package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
  232. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  233. package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
  234. package/dist/types/CallSettings/constants.d.ts +11 -11
  235. package/dist/types/CallSettings/testFixtures.d.ts +15 -15
  236. package/dist/types/CallSettings/types.d.ts +108 -107
  237. package/dist/types/CallSettings/types.d.ts.map +1 -1
  238. package/dist/types/CallingClient/CallingClient.d.ts +37 -35
  239. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  240. package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
  241. package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
  242. package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
  243. package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
  244. package/dist/types/CallingClient/calling/CallerId/types.d.ts.map +1 -1
  245. package/dist/types/CallingClient/calling/call.d.ts +98 -96
  246. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  247. package/dist/types/CallingClient/calling/callManager.d.ts +24 -25
  248. package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
  249. package/dist/types/CallingClient/calling/index.d.ts +2 -2
  250. package/dist/types/CallingClient/calling/types.d.ts +206 -206
  251. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  252. package/dist/types/CallingClient/callingClientFixtures.d.ts +86 -18
  253. package/dist/types/CallingClient/callingClientFixtures.d.ts.map +1 -1
  254. package/dist/types/CallingClient/constants.d.ts +126 -122
  255. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  256. package/dist/types/CallingClient/line/index.d.ts +43 -43
  257. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  258. package/dist/types/CallingClient/line/types.d.ts +43 -55
  259. package/dist/types/CallingClient/line/types.d.ts.map +1 -1
  260. package/dist/types/CallingClient/registration/index.d.ts +1 -1
  261. package/dist/types/CallingClient/registration/register.d.ts +64 -64
  262. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  263. package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
  264. package/dist/types/CallingClient/registration/types.d.ts +20 -20
  265. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  266. package/dist/types/CallingClient/types.d.ts +31 -29
  267. package/dist/types/CallingClient/types.d.ts.map +1 -1
  268. package/dist/types/Contacts/ContactsClient.d.ts +27 -26
  269. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  270. package/dist/types/Contacts/constants.d.ts +19 -19
  271. package/dist/types/Contacts/contactFixtures.d.ts +280 -280
  272. package/dist/types/Contacts/types.d.ts +74 -72
  273. package/dist/types/Contacts/types.d.ts.map +1 -1
  274. package/dist/types/Errors/catalog/CallError.d.ts +11 -11
  275. package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
  276. package/dist/types/Errors/catalog/CallingDeviceError.d.ts.map +1 -1
  277. package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
  278. package/dist/types/Errors/catalog/LineError.d.ts +10 -10
  279. package/dist/types/Errors/catalog/LineError.d.ts.map +1 -1
  280. package/dist/types/Errors/index.d.ts +3 -2
  281. package/dist/types/Errors/index.d.ts.map +1 -1
  282. package/dist/types/Errors/types.d.ts +59 -60
  283. package/dist/types/Errors/types.d.ts.map +1 -1
  284. package/dist/types/Events/impl/index.d.ts +8 -8
  285. package/dist/types/Events/types.d.ts +311 -288
  286. package/dist/types/Events/types.d.ts.map +1 -1
  287. package/dist/types/Logger/index.d.ts +12 -12
  288. package/dist/types/Logger/types.d.ts +25 -25
  289. package/dist/types/Metrics/index.d.ts +5 -5
  290. package/dist/types/Metrics/types.d.ts +42 -42
  291. package/dist/types/SDKConnector/index.d.ts +12 -12
  292. package/dist/types/SDKConnector/types.d.ts +129 -128
  293. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  294. package/dist/types/SDKConnector/utils.d.ts +5 -5
  295. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
  296. package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
  297. package/dist/types/Voicemail/Voicemail.d.ts +27 -27
  298. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  299. package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
  300. package/dist/types/Voicemail/constants.d.ts +29 -29
  301. package/dist/types/Voicemail/types.d.ts +133 -133
  302. package/dist/types/Voicemail/types.d.ts.map +1 -1
  303. package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
  304. package/dist/types/api.d.ts +16 -16
  305. package/dist/types/api.d.ts.map +1 -1
  306. package/dist/types/common/Utils.d.ts +34 -34
  307. package/dist/types/common/Utils.d.ts.map +1 -1
  308. package/dist/types/common/constants.d.ts +41 -41
  309. package/dist/types/common/index.d.ts +1 -1
  310. package/dist/types/common/testUtil.d.ts +3612 -3611
  311. package/dist/types/common/testUtil.d.ts.map +1 -1
  312. package/dist/types/common/types.d.ts +192 -191
  313. package/dist/types/common/types.d.ts.map +1 -1
  314. package/dist/types/index.d.ts +21 -8
  315. package/dist/types/index.d.ts.map +1 -1
  316. package/package.json +5 -3
@@ -1,284 +1,278 @@
1
- import { CALL_MANAGER_FILE } from '../constants';
2
- import { CALLING_CLIENT_EVENT_KEYS, LINE_EVENT_KEYS } from '../../Events/types';
3
- import { Eventing } from '../../Events/impl';
4
- import SDKConnector from '../../SDKConnector';
5
- import { CallDirection } from '../../common/types';
6
- import { MediaState, MobiusEventType, } from './types';
7
- import { createCall } from './call';
8
- import log from '../../Logger';
9
- let callManager;
10
- export class CallManager extends Eventing {
11
- sdkConnector;
12
- webex;
13
- callCollection;
14
- activeMobiusUrl;
15
- serviceIndicator;
16
- lineDict;
17
- constructor(webex, indicator) {
18
- super();
19
- this.sdkConnector = SDKConnector;
20
- this.serviceIndicator = indicator;
21
- if (!this.sdkConnector.getWebex()) {
22
- SDKConnector.setWebex(webex);
23
- }
24
- this.lineDict = {};
25
- this.webex = this.sdkConnector.getWebex();
26
- this.callCollection = {};
27
- this.activeMobiusUrl = '';
28
- this.listenForWsEvents();
29
- }
30
- createCall = (destination, direction, deviceId, lineId) => {
31
- log.log('Creating call object', {});
32
- const newCall = createCall(this.activeMobiusUrl, this.webex, destination, direction, deviceId, lineId, (correlationId) => {
33
- delete this.callCollection[correlationId];
34
- const activeCalls = Object.keys(this.getActiveCalls()).length;
35
- log.info(`DELETE:: Deleted corelationId: ${newCall.getCorrelationId()} from CallManager, Number of call records :- ${activeCalls}`, {});
36
- if (activeCalls === 0) {
37
- this.emit(CALLING_CLIENT_EVENT_KEYS.ALL_CALLS_CLEARED);
38
- }
39
- }, this.serviceIndicator);
40
- this.callCollection[newCall.getCorrelationId()] = newCall;
41
- log.log(`New call created with correlationId: ${newCall.getCorrelationId()}`, {});
42
- log.info(`ADD:: Added corelationId: ${newCall.getCorrelationId()} to CallManager , Number of call records now:- ${Object.keys(this.getActiveCalls()).length}`, {});
43
- return newCall;
44
- };
45
- updateActiveMobius(url) {
46
- this.activeMobiusUrl = url;
47
- }
48
- listenForWsEvents() {
49
- this.sdkConnector.registerListener('event:mobius', async (event) => {
50
- this.dequeueWsEvents(event);
51
- });
52
- }
53
- dequeueWsEvents(event) {
54
- const mobiusEvent = event;
55
- const { callId, correlationId } = mobiusEvent.data;
56
- switch (mobiusEvent.data.eventType) {
57
- case MobiusEventType.CALL_SETUP: {
58
- log.log(`Received call Setup message for call: ${callId}`, {
59
- file: CALL_MANAGER_FILE,
60
- method: 'dequeueWsEvents',
61
- });
62
- if (mobiusEvent.data.midCallService) {
63
- mobiusEvent.data.midCallService.forEach((midCallEvent) => {
64
- const call = this.getCall(correlationId);
65
- if (call) {
66
- call.handleMidCallEvent(midCallEvent);
67
- }
68
- else {
69
- log.log(`Dropping midcall event of type: ${midCallEvent.eventType} as it doesn't match with any existing call`, {
70
- file: CALL_MANAGER_FILE,
71
- method: 'dequeueWsEvents',
72
- });
73
- }
74
- });
75
- return;
76
- }
77
- const newId = Object.keys(this.callCollection).find((id) => this.callCollection[id].getCallId() === callId);
78
- let newCall;
79
- if (!newId) {
80
- const lineId = this.getLineId(mobiusEvent.data.deviceId);
81
- newCall = this.createCall({}, CallDirection.INBOUND, mobiusEvent.data.deviceId, lineId);
82
- log.log(`New incoming call created with correlationId from Call Setup message: ${newCall.getCorrelationId()}`, {
83
- file: CALL_MANAGER_FILE,
84
- method: 'dequeueWsEvents',
85
- });
86
- newCall.setCallId(callId);
87
- if (mobiusEvent.data.broadworksCorrelationInfo) {
88
- log.log(`Found broadworksCorrelationInfo: ${mobiusEvent.data.broadworksCorrelationInfo}`, {
89
- file: CALL_MANAGER_FILE,
90
- method: 'dequeueWsEvents',
91
- });
92
- newCall.setBroadworksCorrelationInfo(mobiusEvent.data.broadworksCorrelationInfo);
93
- }
94
- }
95
- else {
96
- log.info(`Found the call Object with a matching callId: ${callId} from our records with correlationId: ${newId}`, {
97
- file: CALL_MANAGER_FILE,
98
- method: 'dequeueWsEvents',
99
- });
100
- newCall = this.getCall(newId);
101
- }
102
- if (mobiusEvent.data.callerId) {
103
- log.info('Processing Caller-Id data', {
104
- file: CALL_MANAGER_FILE,
105
- method: 'dequeueWsEvents',
106
- });
107
- newCall.startCallerIdResolution(mobiusEvent.data.callerId);
108
- }
109
- this.emit(LINE_EVENT_KEYS.INCOMING_CALL, newCall);
110
- newCall.sendCallStateMachineEvt({ type: 'E_RECV_CALL_SETUP', data: mobiusEvent.data });
111
- break;
112
- }
113
- case MobiusEventType.CALL_PROGRESS: {
114
- log.log(`Received call progress mobiusEvent for call: ${correlationId}`, {
115
- file: CALL_MANAGER_FILE,
116
- method: 'dequeueWsEvents',
117
- });
118
- const call = this.getCall(correlationId);
119
- call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_PROGRESS', data: mobiusEvent.data });
120
- break;
121
- }
122
- case MobiusEventType.CALL_MEDIA: {
123
- log.log(`Received call media mobiusEvent for call: ${correlationId}`, {
124
- file: CALL_MANAGER_FILE,
125
- method: 'dequeueWsEvents',
126
- });
127
- let activeCall;
128
- if (correlationId) {
129
- activeCall = this.getCall(correlationId);
130
- }
131
- else {
132
- const newId = Object.keys(this.callCollection).find((id) => this.callCollection[id].getCallId() === callId);
133
- if (newId) {
134
- log.info(`Found the call Object with a matching callId: ${callId} from our records with correlationId: ${newId}`, {
135
- file: CALL_MANAGER_FILE,
136
- method: 'dequeueWsEvents',
137
- });
138
- activeCall = this.getCall(newId);
139
- }
140
- else {
141
- const lineId = this.getLineId(mobiusEvent.data.deviceId);
142
- activeCall = this.createCall({}, CallDirection.INBOUND, mobiusEvent.data.deviceId, lineId);
143
- log.log(`New incoming call created with correlationId from ROAP Message: ${activeCall.getCorrelationId()}`, {
144
- file: CALL_MANAGER_FILE,
145
- method: 'dequeueWsEvents',
146
- });
147
- activeCall.setCallId(callId);
148
- }
149
- }
150
- if (activeCall) {
151
- log.info(`SDP from mobius ${mobiusEvent.data.message?.sdp}`, {
152
- file: CALL_MANAGER_FILE,
153
- method: 'dequeueWsEvents',
154
- });
155
- log.log(`ROAP message from mobius with type: ${mobiusEvent.data.message?.messageType}, seq: ${mobiusEvent.data.message?.seq} , version: ${mobiusEvent.data.message?.version}`, {
156
- file: CALL_MANAGER_FILE,
157
- method: 'dequeueWsEvents',
158
- });
159
- const mediaState = mobiusEvent.data.message?.messageType;
160
- switch (mediaState) {
161
- case MediaState.OFFER: {
162
- log.log('Received OFFER', {
163
- file: CALL_MANAGER_FILE,
164
- method: 'dequeueWsEvents',
165
- });
166
- activeCall.sendMediaStateMachineEvt({
167
- type: 'E_RECV_ROAP_OFFER',
168
- data: mobiusEvent.data.message,
169
- });
170
- break;
171
- }
172
- case MediaState.ANSWER: {
173
- log.log('Received ANSWER', {
174
- file: CALL_MANAGER_FILE,
175
- method: 'dequeueWsEvents',
176
- });
177
- activeCall.sendMediaStateMachineEvt({
178
- type: 'E_RECV_ROAP_ANSWER',
179
- data: mobiusEvent.data.message,
180
- });
181
- break;
182
- }
183
- case MediaState.OFFER_REQUEST: {
184
- log.log('Received OFFER_REQUEST', {
185
- file: CALL_MANAGER_FILE,
186
- method: 'dequeueWsEvents',
187
- });
188
- activeCall.sendMediaStateMachineEvt({
189
- type: 'E_RECV_ROAP_OFFER_REQUEST',
190
- data: mobiusEvent.data.message,
191
- });
192
- break;
193
- }
194
- case MediaState.OK: {
195
- log.log('Received OK', {
196
- file: CALL_MANAGER_FILE,
197
- method: 'dequeueWsEvents',
198
- });
199
- const mediaOk = {
200
- received: true,
201
- message: mobiusEvent.data.message,
202
- };
203
- activeCall.sendMediaStateMachineEvt({
204
- type: 'E_ROAP_OK',
205
- data: mediaOk,
206
- });
207
- break;
208
- }
209
- case MediaState.ERROR: {
210
- log.log('Received Error...', {
211
- file: CALL_MANAGER_FILE,
212
- method: 'dequeueWsEvents',
213
- });
214
- break;
215
- }
216
- default: {
217
- log.log(`Unknown Media mobiusEvent: ${mediaState} `, {
218
- file: CALL_MANAGER_FILE,
219
- method: 'dequeueWsEvents',
220
- });
221
- }
222
- }
223
- }
224
- else {
225
- log.log(`CorrelationId: ${correlationId} doesn't exist , discarding..`, {
226
- file: CALL_MANAGER_FILE,
227
- method: 'dequeueWsEvents',
228
- });
229
- }
230
- break;
231
- }
232
- case MobiusEventType.CALL_CONNECTED: {
233
- log.log(`Received call connect for call: ${correlationId}`, {
234
- file: CALL_MANAGER_FILE,
235
- method: 'dequeueWsEvents',
236
- });
237
- const call = this.getCall(correlationId);
238
- call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_CONNECT', data: mobiusEvent.data });
239
- break;
240
- }
241
- case MobiusEventType.CALL_DISCONNECTED: {
242
- log.log(`Received call disconnect for call: ${correlationId}`, {
243
- file: CALL_MANAGER_FILE,
244
- method: 'dequeueWsEvents',
245
- });
246
- const call = this.getCall(correlationId);
247
- if (call) {
248
- call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_DISCONNECT' });
249
- }
250
- break;
251
- }
252
- default: {
253
- log.log(`Unknown Call Event mobiusEvent: ${mobiusEvent.data.eventType}`, {
254
- file: CALL_MANAGER_FILE,
255
- method: 'dequeueWsEvents',
256
- });
257
- }
258
- }
259
- }
260
- endCall = (correlationId) => {
261
- const call = this.getCall(correlationId);
262
- if (call) {
263
- call.end();
264
- }
265
- };
266
- getCall = (correlationId) => {
267
- return this.callCollection[correlationId];
268
- };
269
- getActiveCalls = () => {
270
- return this.callCollection;
271
- };
272
- updateLine(deviceId, line) {
273
- this.lineDict[deviceId] = line;
274
- }
275
- getLineId(deviceId) {
276
- return this.lineDict[deviceId].lineId;
277
- }
278
- }
279
- export const getCallManager = (webex, indicator) => {
280
- if (!callManager) {
281
- callManager = new CallManager(webex, indicator);
282
- }
283
- return callManager;
284
- };
1
+ import { CALL_MANAGER_FILE } from '../constants';
2
+ import { CALLING_CLIENT_EVENT_KEYS, LINE_EVENT_KEYS } from '../../Events/types';
3
+ import { Eventing } from '../../Events/impl';
4
+ import SDKConnector from '../../SDKConnector';
5
+ import { CallDirection } from '../../common/types';
6
+ import { MediaState, MobiusEventType, } from './types';
7
+ import { createCall } from './call';
8
+ import log from '../../Logger';
9
+ let callManager;
10
+ export class CallManager extends Eventing {
11
+ sdkConnector;
12
+ webex;
13
+ callCollection;
14
+ activeMobiusUrl;
15
+ serviceIndicator;
16
+ lineDict;
17
+ constructor(webex, indicator) {
18
+ super();
19
+ this.sdkConnector = SDKConnector;
20
+ this.serviceIndicator = indicator;
21
+ if (!this.sdkConnector.getWebex()) {
22
+ SDKConnector.setWebex(webex);
23
+ }
24
+ this.lineDict = {};
25
+ this.webex = this.sdkConnector.getWebex();
26
+ this.callCollection = {};
27
+ this.activeMobiusUrl = '';
28
+ this.listenForWsEvents();
29
+ }
30
+ createCall = (destination, direction, deviceId, lineId) => {
31
+ log.log('Creating call object', {});
32
+ const newCall = createCall(this.activeMobiusUrl, this.webex, destination, direction, deviceId, lineId, (correlationId) => {
33
+ delete this.callCollection[correlationId];
34
+ const activeCalls = Object.keys(this.getActiveCalls()).length;
35
+ log.info(`DELETE:: Deleted corelationId: ${newCall.getCorrelationId()} from CallManager, Number of call records :- ${activeCalls}`, {});
36
+ if (activeCalls === 0) {
37
+ this.emit(CALLING_CLIENT_EVENT_KEYS.ALL_CALLS_CLEARED);
38
+ }
39
+ }, this.serviceIndicator);
40
+ this.callCollection[newCall.getCorrelationId()] = newCall;
41
+ log.log(`New call created with correlationId: ${newCall.getCorrelationId()}`, {});
42
+ log.info(`ADD:: Added corelationId: ${newCall.getCorrelationId()} to CallManager , Number of call records now:- ${Object.keys(this.getActiveCalls()).length}`, {});
43
+ return newCall;
44
+ };
45
+ updateActiveMobius(url) {
46
+ this.activeMobiusUrl = url;
47
+ }
48
+ listenForWsEvents() {
49
+ this.sdkConnector.registerListener('event:mobius', async (event) => {
50
+ this.dequeueWsEvents(event);
51
+ });
52
+ }
53
+ dequeueWsEvents(event) {
54
+ const mobiusEvent = event;
55
+ const { callId, correlationId } = mobiusEvent.data;
56
+ switch (mobiusEvent.data.eventType) {
57
+ case MobiusEventType.CALL_SETUP: {
58
+ log.log(`Received call Setup message for call: ${callId}`, {
59
+ file: CALL_MANAGER_FILE,
60
+ method: 'dequeueWsEvents',
61
+ });
62
+ if (mobiusEvent.data.midCallService) {
63
+ mobiusEvent.data.midCallService.forEach((midCallEvent) => {
64
+ const call = this.getCall(correlationId);
65
+ if (call) {
66
+ call.handleMidCallEvent(midCallEvent);
67
+ }
68
+ else {
69
+ log.log(`Dropping midcall event of type: ${midCallEvent.eventType} as it doesn't match with any existing call`, {
70
+ file: CALL_MANAGER_FILE,
71
+ method: 'dequeueWsEvents',
72
+ });
73
+ }
74
+ });
75
+ return;
76
+ }
77
+ const newId = Object.keys(this.callCollection).find((id) => this.callCollection[id].getCallId() === callId);
78
+ let newCall;
79
+ if (!newId) {
80
+ const lineId = this.getLineId(mobiusEvent.data.deviceId);
81
+ newCall = this.createCall({}, CallDirection.INBOUND, mobiusEvent.data.deviceId, lineId);
82
+ log.log(`New incoming call created with correlationId from Call Setup message: ${newCall.getCorrelationId()}`, {
83
+ file: CALL_MANAGER_FILE,
84
+ method: 'dequeueWsEvents',
85
+ });
86
+ newCall.setCallId(callId);
87
+ if (mobiusEvent.data.broadworksCorrelationInfo) {
88
+ log.log(`Found broadworksCorrelationInfo: ${mobiusEvent.data.broadworksCorrelationInfo}`, {
89
+ file: CALL_MANAGER_FILE,
90
+ method: 'dequeueWsEvents',
91
+ });
92
+ newCall.setBroadworksCorrelationInfo(mobiusEvent.data.broadworksCorrelationInfo);
93
+ }
94
+ }
95
+ else {
96
+ log.info(`Found the call Object with a matching callId: ${callId} from our records with correlationId: ${newId}`, {
97
+ file: CALL_MANAGER_FILE,
98
+ method: 'dequeueWsEvents',
99
+ });
100
+ newCall = this.getCall(newId);
101
+ }
102
+ if (mobiusEvent.data.callerId) {
103
+ log.info('Processing Caller-Id data', {
104
+ file: CALL_MANAGER_FILE,
105
+ method: 'dequeueWsEvents',
106
+ });
107
+ newCall.startCallerIdResolution(mobiusEvent.data.callerId);
108
+ }
109
+ this.emit(LINE_EVENT_KEYS.INCOMING_CALL, newCall);
110
+ newCall.sendCallStateMachineEvt({ type: 'E_RECV_CALL_SETUP', data: mobiusEvent.data });
111
+ break;
112
+ }
113
+ case MobiusEventType.CALL_PROGRESS: {
114
+ log.log(`Received call progress mobiusEvent for call: ${correlationId}`, {
115
+ file: CALL_MANAGER_FILE,
116
+ method: 'dequeueWsEvents',
117
+ });
118
+ const call = this.getCall(correlationId);
119
+ call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_PROGRESS', data: mobiusEvent.data });
120
+ break;
121
+ }
122
+ case MobiusEventType.CALL_MEDIA: {
123
+ log.log(`Received call media mobiusEvent for call: ${correlationId}`, {
124
+ file: CALL_MANAGER_FILE,
125
+ method: 'dequeueWsEvents',
126
+ });
127
+ let activeCall;
128
+ if (correlationId) {
129
+ activeCall = this.getCall(correlationId);
130
+ }
131
+ else {
132
+ const newId = Object.keys(this.callCollection).find((id) => this.callCollection[id].getCallId() === callId);
133
+ if (newId) {
134
+ log.info(`Found the call Object with a matching callId: ${callId} from our records with correlationId: ${newId}`, {
135
+ file: CALL_MANAGER_FILE,
136
+ method: 'dequeueWsEvents',
137
+ });
138
+ activeCall = this.getCall(newId);
139
+ }
140
+ else {
141
+ const lineId = this.getLineId(mobiusEvent.data.deviceId);
142
+ activeCall = this.createCall({}, CallDirection.INBOUND, mobiusEvent.data.deviceId, lineId);
143
+ log.log(`New incoming call created with correlationId from ROAP Message: ${activeCall.getCorrelationId()}`, {
144
+ file: CALL_MANAGER_FILE,
145
+ method: 'dequeueWsEvents',
146
+ });
147
+ activeCall.setCallId(callId);
148
+ }
149
+ }
150
+ if (activeCall) {
151
+ log.info(`SDP from mobius ${mobiusEvent.data.message?.sdp}`, {
152
+ file: CALL_MANAGER_FILE,
153
+ method: 'dequeueWsEvents',
154
+ });
155
+ log.log(`ROAP message from mobius with type: ${mobiusEvent.data.message?.messageType}, seq: ${mobiusEvent.data.message?.seq} , version: ${mobiusEvent.data.message?.version}`, {
156
+ file: CALL_MANAGER_FILE,
157
+ method: 'dequeueWsEvents',
158
+ });
159
+ const mediaState = mobiusEvent.data.message?.messageType;
160
+ switch (mediaState) {
161
+ case MediaState.OFFER: {
162
+ log.log('Received OFFER', {
163
+ file: CALL_MANAGER_FILE,
164
+ method: 'dequeueWsEvents',
165
+ });
166
+ activeCall.sendMediaStateMachineEvt({
167
+ type: 'E_RECV_ROAP_OFFER',
168
+ data: mobiusEvent.data.message,
169
+ });
170
+ break;
171
+ }
172
+ case MediaState.ANSWER: {
173
+ log.log('Received ANSWER', {
174
+ file: CALL_MANAGER_FILE,
175
+ method: 'dequeueWsEvents',
176
+ });
177
+ activeCall.sendMediaStateMachineEvt({
178
+ type: 'E_RECV_ROAP_ANSWER',
179
+ data: mobiusEvent.data.message,
180
+ });
181
+ break;
182
+ }
183
+ case MediaState.OFFER_REQUEST: {
184
+ log.log('Received OFFER_REQUEST', {
185
+ file: CALL_MANAGER_FILE,
186
+ method: 'dequeueWsEvents',
187
+ });
188
+ activeCall.sendMediaStateMachineEvt({
189
+ type: 'E_RECV_ROAP_OFFER_REQUEST',
190
+ data: mobiusEvent.data.message,
191
+ });
192
+ break;
193
+ }
194
+ case MediaState.OK: {
195
+ log.log('Received OK', {
196
+ file: CALL_MANAGER_FILE,
197
+ method: 'dequeueWsEvents',
198
+ });
199
+ const mediaOk = {
200
+ received: true,
201
+ message: mobiusEvent.data.message,
202
+ };
203
+ activeCall.sendMediaStateMachineEvt({
204
+ type: 'E_ROAP_OK',
205
+ data: mediaOk,
206
+ });
207
+ break;
208
+ }
209
+ case MediaState.ERROR: {
210
+ log.log('Received Error...', {
211
+ file: CALL_MANAGER_FILE,
212
+ method: 'dequeueWsEvents',
213
+ });
214
+ break;
215
+ }
216
+ default: {
217
+ log.log(`Unknown Media mobiusEvent: ${mediaState} `, {
218
+ file: CALL_MANAGER_FILE,
219
+ method: 'dequeueWsEvents',
220
+ });
221
+ }
222
+ }
223
+ }
224
+ else {
225
+ log.log(`CorrelationId: ${correlationId} doesn't exist , discarding..`, {
226
+ file: CALL_MANAGER_FILE,
227
+ method: 'dequeueWsEvents',
228
+ });
229
+ }
230
+ break;
231
+ }
232
+ case MobiusEventType.CALL_CONNECTED: {
233
+ log.log(`Received call connect for call: ${correlationId}`, {
234
+ file: CALL_MANAGER_FILE,
235
+ method: 'dequeueWsEvents',
236
+ });
237
+ const call = this.getCall(correlationId);
238
+ call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_CONNECT', data: mobiusEvent.data });
239
+ break;
240
+ }
241
+ case MobiusEventType.CALL_DISCONNECTED: {
242
+ log.log(`Received call disconnect for call: ${correlationId}`, {
243
+ file: CALL_MANAGER_FILE,
244
+ method: 'dequeueWsEvents',
245
+ });
246
+ const call = this.getCall(correlationId);
247
+ if (call) {
248
+ call.sendCallStateMachineEvt({ type: 'E_RECV_CALL_DISCONNECT' });
249
+ }
250
+ break;
251
+ }
252
+ default: {
253
+ log.log(`Unknown Call Event mobiusEvent: ${mobiusEvent.data.eventType}`, {
254
+ file: CALL_MANAGER_FILE,
255
+ method: 'dequeueWsEvents',
256
+ });
257
+ }
258
+ }
259
+ }
260
+ getCall = (correlationId) => {
261
+ return this.callCollection[correlationId];
262
+ };
263
+ getActiveCalls = () => {
264
+ return this.callCollection;
265
+ };
266
+ updateLine(deviceId, line) {
267
+ this.lineDict[deviceId] = line;
268
+ }
269
+ getLineId(deviceId) {
270
+ return this.lineDict[deviceId].lineId;
271
+ }
272
+ }
273
+ export const getCallManager = (webex, indicator) => {
274
+ if (!callManager) {
275
+ callManager = new CallManager(webex, indicator);
276
+ }
277
+ return callManager;
278
+ };
@@ -1,2 +1,2 @@
1
- export * from './call';
2
- export * from './callManager';
1
+ export * from './call';
2
+ export * from './callManager';