@voicenter-team/opensips-js 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/build/helpers/jssip.d.ts +5 -0
- package/build/helpers/jssip.js +30 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +27 -7
- package/package.json +1 -1
- package/src/types/rtc.d.ts +8 -1
@@ -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
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const jssip_1 = __importDefault(require("jssip"));
|
16
16
|
const UA_1 = __importDefault(require("./helpers/UA"));
|
17
|
+
const RTCSession_1 = require("jssip/lib/RTCSession");
|
17
18
|
const p_iteration_1 = require("p-iteration");
|
18
19
|
const time_helper_1 = require("./helpers/time.helper");
|
19
20
|
const filter_helper_1 = require("./helpers/filter.helper");
|
@@ -36,6 +37,7 @@ class OpenSIPSJS extends UA_1.default {
|
|
36
37
|
this.activeCalls = {};
|
37
38
|
this.state = {
|
38
39
|
isMuted: false,
|
40
|
+
isAutoAnswer: false,
|
39
41
|
activeCalls: {},
|
40
42
|
availableMediaDevices: [],
|
41
43
|
selectedMediaDevices: {
|
@@ -82,6 +84,12 @@ class OpenSIPSJS extends UA_1.default {
|
|
82
84
|
this._currentActiveRoomId = roomId;
|
83
85
|
this.emit('currentActiveRoomChanged', roomId);
|
84
86
|
}
|
87
|
+
get autoAnswer() {
|
88
|
+
return this.state.isAutoAnswer;
|
89
|
+
}
|
90
|
+
set autoAnswer(value) {
|
91
|
+
this.state.isAutoAnswer = value;
|
92
|
+
}
|
85
93
|
get callAddingInProgress() {
|
86
94
|
return this._callAddingInProgress;
|
87
95
|
}
|
@@ -264,7 +272,7 @@ class OpenSIPSJS extends UA_1.default {
|
|
264
272
|
}
|
265
273
|
_cancelAllOutgoingUnanswered() {
|
266
274
|
Object.values(this.getActiveCalls).filter(call => {
|
267
|
-
return call.direction ===
|
275
|
+
return call.direction === RTCSession_1.SessionDirection.OUTGOING
|
268
276
|
&& call.status === CALL_STATUS_UNANSWERED;
|
269
277
|
}).forEach(call => this.callTerminate(call._id));
|
270
278
|
}
|
@@ -296,10 +304,12 @@ class OpenSIPSJS extends UA_1.default {
|
|
296
304
|
this.state.activeRooms = Object.assign(Object.assign({}, this.state.activeRooms), { [value.roomId]: Object.assign({}, newRoomData) });
|
297
305
|
this.emit('updateRoom', { room: newRoomData, roomList: this.state.activeRooms });
|
298
306
|
}
|
299
|
-
_addCall(value) {
|
307
|
+
_addCall(value, emitEvent = true) {
|
300
308
|
this.state.activeCalls = Object.assign(Object.assign({}, this.state.activeCalls), { [value._id]: (0, audio_helper_1.simplifyCallObject)(value) });
|
301
309
|
activeCalls[value._id] = value;
|
302
|
-
|
310
|
+
if (emitEvent) {
|
311
|
+
this.emit('changeActiveCalls', this.state.activeCalls);
|
312
|
+
}
|
303
313
|
}
|
304
314
|
_addCallStatus(callId) {
|
305
315
|
this.state.callStatus = Object.assign(Object.assign({}, this.state.callStatus), { [callId]: {
|
@@ -638,7 +648,7 @@ class OpenSIPSJS extends UA_1.default {
|
|
638
648
|
incomingInProgress: false,
|
639
649
|
roomId
|
640
650
|
};
|
641
|
-
if (session.direction ===
|
651
|
+
if (session.direction === RTCSession_1.SessionDirection.INCOMING) {
|
642
652
|
newRoomInfo.incomingInProgress = true;
|
643
653
|
this.subscribe(call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_CONFIRMED, (call) => {
|
644
654
|
if (session.id === call.id) {
|
@@ -658,15 +668,25 @@ class OpenSIPSJS extends UA_1.default {
|
|
658
668
|
}
|
659
669
|
});
|
660
670
|
}
|
661
|
-
else if (session.direction ===
|
671
|
+
else if (session.direction === RTCSession_1.SessionDirection.OUTGOING) {
|
662
672
|
this._startCallTimer(session.id);
|
663
673
|
}
|
664
674
|
const call = session;
|
665
675
|
call.roomId = roomId;
|
666
676
|
call.localMuted = false;
|
667
|
-
this.
|
677
|
+
const doAutoAnswer = call.direction === RTCSession_1.SessionDirection.INCOMING && this.autoAnswer;
|
678
|
+
if (doAutoAnswer) {
|
679
|
+
this._addCall(call, false);
|
680
|
+
}
|
681
|
+
else {
|
682
|
+
this._addCall(call);
|
683
|
+
}
|
684
|
+
// this._addCall(call)
|
668
685
|
this._addCallStatus(session.id);
|
669
686
|
this._addRoom(newRoomInfo);
|
687
|
+
if (doAutoAnswer) {
|
688
|
+
this.callAnswer(call._id);
|
689
|
+
}
|
670
690
|
});
|
671
691
|
}
|
672
692
|
_triggerListener({ listenerType, session, event }) {
|
@@ -733,7 +753,7 @@ class OpenSIPSJS extends UA_1.default {
|
|
733
753
|
}
|
734
754
|
});
|
735
755
|
this.addCall(session);
|
736
|
-
if (session.direction ===
|
756
|
+
if (session.direction === RTCSession_1.SessionDirection.OUTGOING) {
|
737
757
|
const roomId = this.getActiveCalls[session.id].roomId;
|
738
758
|
this.setCurrentActiveRoomId(roomId);
|
739
759
|
}
|
package/package.json
CHANGED
package/src/types/rtc.d.ts
CHANGED
@@ -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:
|
69
|
+
_remote_identity: RemoteIdentityCallType
|
63
70
|
answer(options?: AnswerOptionsExtended): void
|
64
71
|
}
|
65
72
|
|