@voicenter-team/opensips-js 1.0.10 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ import { SessionDirection } from 'jssip/lib/RTCSession';
2
+ export { SessionDirection };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionDirection = void 0;
4
+ const RTCSession_1 = require("jssip/lib/RTCSession");
5
+ Object.defineProperty(exports, "SessionDirection", { enumerable: true, get: function () { return RTCSession_1.SessionDirection; } });
@@ -0,0 +1,5 @@
1
+ import JsSIP, { UA } from 'jssip';
2
+ import { IncomingAckEvent, IncomingEvent, OutgoingAckEvent, OutgoingEvent } from 'jssip/lib/RTCSession';
3
+ import { RTCSessionEvent, UAConfiguration, UAEventMap } from 'jssip/lib/UA';
4
+ export default JsSIP;
5
+ export { UA, IncomingAckEvent, IncomingEvent, OutgoingAckEvent, OutgoingEvent, RTCSessionEvent, UAConfiguration, UAEventMap };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.UA = void 0;
27
+ // @ts-nocheck
28
+ const jssip_1 = __importStar(require("jssip"));
29
+ Object.defineProperty(exports, "UA", { enumerable: true, get: function () { return jssip_1.UA; } });
30
+ exports.default = jssip_1.default;
package/build/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export interface InnerState {
38
38
  [key: string]: Array<(call: RTCSessionExtended, event: ListenerEventType | undefined) => void>;
39
39
  };
40
40
  metricConfig: WebrtcMetricsConfigType;
41
+ isAutoAnswer: boolean;
41
42
  }
42
43
  declare class OpenSIPSJS extends UA {
43
44
  private initialized;
@@ -67,6 +68,8 @@ declare class OpenSIPSJS extends UA {
67
68
  };
68
69
  get currentActiveRoomId(): number | undefined;
69
70
  private set currentActiveRoomId(value);
71
+ get autoAnswer(): boolean;
72
+ set autoAnswer(value: boolean);
70
73
  get callAddingInProgress(): string | undefined;
71
74
  private set callAddingInProgress(value);
72
75
  get muteWhenJoin(): boolean;
package/build/index.js CHANGED
@@ -36,6 +36,7 @@ class OpenSIPSJS extends UA_1.default {
36
36
  this.activeCalls = {};
37
37
  this.state = {
38
38
  isMuted: false,
39
+ isAutoAnswer: false,
39
40
  activeCalls: {},
40
41
  availableMediaDevices: [],
41
42
  selectedMediaDevices: {
@@ -82,6 +83,12 @@ class OpenSIPSJS extends UA_1.default {
82
83
  this._currentActiveRoomId = roomId;
83
84
  this.emit('currentActiveRoomChanged', roomId);
84
85
  }
86
+ get autoAnswer() {
87
+ return this.state.isAutoAnswer;
88
+ }
89
+ set autoAnswer(value) {
90
+ this.state.isAutoAnswer = value;
91
+ }
85
92
  get callAddingInProgress() {
86
93
  return this._callAddingInProgress;
87
94
  }
@@ -296,10 +303,12 @@ class OpenSIPSJS extends UA_1.default {
296
303
  this.state.activeRooms = Object.assign(Object.assign({}, this.state.activeRooms), { [value.roomId]: Object.assign({}, newRoomData) });
297
304
  this.emit('updateRoom', { room: newRoomData, roomList: this.state.activeRooms });
298
305
  }
299
- _addCall(value) {
306
+ _addCall(value, emitEvent = true) {
300
307
  this.state.activeCalls = Object.assign(Object.assign({}, this.state.activeCalls), { [value._id]: (0, audio_helper_1.simplifyCallObject)(value) });
301
308
  activeCalls[value._id] = value;
302
- this.emit('changeActiveCalls', this.state.activeCalls);
309
+ if (emitEvent) {
310
+ this.emit('changeActiveCalls', this.state.activeCalls);
311
+ }
303
312
  }
304
313
  _addCallStatus(callId) {
305
314
  this.state.callStatus = Object.assign(Object.assign({}, this.state.callStatus), { [callId]: {
@@ -403,7 +412,7 @@ class OpenSIPSJS extends UA_1.default {
403
412
  if (Object.values(activeCalls).filter(call => call.roomId === roomId).length === 0) {
404
413
  this.removeRoom(roomId);
405
414
  if (this.currentActiveRoomId === roomId) {
406
- this.currentActiveRoomId = roomId;
415
+ this.currentActiveRoomId = undefined;
407
416
  }
408
417
  }
409
418
  }
@@ -664,9 +673,19 @@ class OpenSIPSJS extends UA_1.default {
664
673
  const call = session;
665
674
  call.roomId = roomId;
666
675
  call.localMuted = false;
667
- this._addCall(call);
676
+ const doAutoAnswer = call.direction === 'incoming' && this.autoAnswer;
677
+ if (doAutoAnswer) {
678
+ this._addCall(call, false);
679
+ }
680
+ else {
681
+ this._addCall(call);
682
+ }
683
+ // this._addCall(call)
668
684
  this._addCallStatus(session.id);
669
685
  this._addRoom(newRoomInfo);
686
+ if (doAutoAnswer) {
687
+ this.callAnswer(call._id);
688
+ }
670
689
  });
671
690
  }
672
691
  _triggerListener({ listenerType, session, event }) {
@@ -700,6 +719,8 @@ class OpenSIPSJS extends UA_1.default {
700
719
  session.on('ended', (event) => {
701
720
  this._triggerListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_ENDED, session, event });
702
721
  const s = this.getActiveCalls[session.id];
722
+ if (!s)
723
+ return;
703
724
  this._activeCallListRemove(s);
704
725
  this._stopCallTimer(session.id);
705
726
  this._removeCallStatus(session.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicenter-team/opensips-js",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "The JS package for opensips",
5
5
  "default": "src/index.ts",
6
6
  "main": "build/index.js",
@@ -43,6 +43,13 @@ export interface AnswerOptionsExtended extends AnswerOptions {
43
43
  mediaConstraints?: MediaStreamConstraints
44
44
  }
45
45
 
46
+ export interface RemoteIdentityCallType {
47
+ _display_name: string
48
+ _uri: {
49
+ _user: string
50
+ }
51
+ }
52
+
46
53
  export interface RTCSessionExtended extends RTCSession {
47
54
  id: string
48
55
  _automaticHold: boolean
@@ -59,7 +66,7 @@ export interface RTCSessionExtended extends RTCSession {
59
66
  _late_sdp: string
60
67
  _videoMuted: boolean
61
68
  _status: number
62
- _remote_identity: string
69
+ _remote_identity: RemoteIdentityCallType
63
70
  answer(options?: AnswerOptionsExtended): void
64
71
  }
65
72