@webex/calling 0.0.1-next.0 → 0.0.1-next.1

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