podchat-browser 12.9.18 → 12.9.19-snapshot.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.
- package/changelog.md +1 -1
- package/dist/node/buildConfig.json +1 -1
- package/dist/node/chat.js +55 -0
- package/dist/node/lib/call/multitrack/callManager.js +43 -15
- package/dist/node/lib/call/multitrack/callUser.js +55 -4
- package/dist/node/lib/call/multitrack/callUsers.js +4 -0
- package/dist/node/lib/call/multitrack/peerConnectionManager.js +149 -24
- package/dist/node/lib/chat/threadHistoryMethods.js +24 -0
- package/dist/node/lib/chat/threadMethods.js +21 -9
- package/dist/node/lib/errorHandler.js +13 -0
- package/dist/node/lib/helpers/dataFormatters.js +1 -0
- package/dist/podchat-browser-bundle.js +33975 -33404
- package/examples/index.html +41 -4
- package/package.json +1 -1
- package/src/buildConfig.json +1 -1
- package/src/chat.js +48 -0
- package/src/lib/call/multitrack/callManager.js +49 -18
- package/src/lib/call/multitrack/callUser.js +63 -7
- package/src/lib/call/multitrack/callUsers.js +3 -0
- package/src/lib/call/multitrack/peerConnectionManager.js +130 -31
- package/src/lib/chat/threadHistoryMethods.js +24 -3
- package/src/lib/chat/threadMethods.js +20 -10
- package/src/lib/errorHandler.js +18 -0
- package/src/lib/helpers/dataFormatters.js +1 -0
- package/src/lib/store/history/index.js +1 -1
package/changelog.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"12.9.
|
|
1
|
+
{"version":"12.9.19-snapshot.1","date":"۱۴۰۴/۱۱/۱۴","VersionInfo":"Release: false, Snapshot: true, Is For Test: true"}
|
package/dist/node/chat.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
10
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
13
|
|
|
12
14
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
@@ -47,6 +49,10 @@ var _dataFormatters = require("./lib/helpers/dataFormatters");
|
|
|
47
49
|
|
|
48
50
|
var _sdkParams = require("./lib/sdkParams");
|
|
49
51
|
|
|
52
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
|
+
|
|
54
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
55
|
+
|
|
50
56
|
function Chat(params) {
|
|
51
57
|
/*******************************************************
|
|
52
58
|
* P R I V A T E V A R I A B L E S *
|
|
@@ -8929,6 +8935,55 @@ function Chat(params) {
|
|
|
8929
8935
|
return app.call.currentCall();
|
|
8930
8936
|
};
|
|
8931
8937
|
|
|
8938
|
+
publicized.sendCallData = function (params) {
|
|
8939
|
+
if (!app.call.currentCall()) {
|
|
8940
|
+
app.errorHandler.raiseError(app.errorHandler.getFilledErrorObject(_objectSpread(_objectSpread({}, _errorHandler.errorList.INVALID_CALLID), {}, {
|
|
8941
|
+
replacements: ['sendCallData']
|
|
8942
|
+
})), null, true, {});
|
|
8943
|
+
return;
|
|
8944
|
+
}
|
|
8945
|
+
|
|
8946
|
+
if (!app.sdkParams.callOptions.enableDataChannel) {
|
|
8947
|
+
app.errorHandler.raiseError({
|
|
8948
|
+
code: _errorHandler.errorList.DATACHANNEL_NOT_ENABLED.code,
|
|
8949
|
+
message: _errorHandler.errorList.DATACHANNEL_NOT_ENABLED.message
|
|
8950
|
+
}, null, true, {});
|
|
8951
|
+
return;
|
|
8952
|
+
}
|
|
8953
|
+
|
|
8954
|
+
if ((0, _typeof2["default"])(params.jsonData) != "object") {
|
|
8955
|
+
app.errorHandler.raiseError(app.errorHandler.getFilledErrorObject(_objectSpread(_objectSpread({}, _errorHandler.errorList.ONLY_OBJECT_IS_ALLOWED), {}, {
|
|
8956
|
+
variables: ['parameterName', 'methodName', 'parameterType'],
|
|
8957
|
+
replacements: ["jsonData", "sendCallData", "object"]
|
|
8958
|
+
})), null, true, {});
|
|
8959
|
+
}
|
|
8960
|
+
|
|
8961
|
+
app.call.currentCall().sendCallData(params.jsonData);
|
|
8962
|
+
};
|
|
8963
|
+
|
|
8964
|
+
publicized.reInit = function (config) {
|
|
8965
|
+
params.socketAddress = config.socketAddress;
|
|
8966
|
+
params.podSpaceFileServer = config.podSpaceUrl;
|
|
8967
|
+
params.platformHost = config.platformHost;
|
|
8968
|
+
|
|
8969
|
+
if (config.webrtcConfig && config.webrtcConfig.iceServers) {
|
|
8970
|
+
config.webrtcConfig.iceServers.forEach(function (item) {
|
|
8971
|
+
if (item.info) {
|
|
8972
|
+
var inf = atob(item.info).split(":");
|
|
8973
|
+
item.username = inf[0];
|
|
8974
|
+
item.credential = inf[1];
|
|
8975
|
+
}
|
|
8976
|
+
});
|
|
8977
|
+
}
|
|
8978
|
+
|
|
8979
|
+
params.webrtcConfig = config.webrtcConfig;
|
|
8980
|
+
params.protocol = config.protocol;
|
|
8981
|
+
(0, _sdkParams.initSdkParams)(app, params);
|
|
8982
|
+
protocolManager.resetRetries();
|
|
8983
|
+
protocolManager.resetTimerTime();
|
|
8984
|
+
protocolManager.switchProtocol(app.sdkParams.protocol);
|
|
8985
|
+
};
|
|
8986
|
+
|
|
8932
8987
|
init();
|
|
8933
8988
|
return publicized;
|
|
8934
8989
|
}
|
|
@@ -538,10 +538,25 @@ function MultiTrackCallManager(_ref) {
|
|
|
538
538
|
sendPeerFailed && createPeerManager('send');
|
|
539
539
|
setTimeout(function () {
|
|
540
540
|
if (sendPeerFailed) {
|
|
541
|
+
if (app.sdkParams.callOptions.enableDataChannel) {
|
|
542
|
+
config.sendPeerManager.startDataChannel();
|
|
543
|
+
config.sendPeerManager.addTrack({
|
|
544
|
+
topic: "data-channel-".concat(config.callId, "-").concat(config.users.get(app.store.user.get().id).user().clientId),
|
|
545
|
+
mediaType: 3,
|
|
546
|
+
//currentTrackId: stream.getTracks()[0].id,
|
|
547
|
+
clientId: config.users.get(app.store.user.get().id).user().clientId,
|
|
548
|
+
onTrackCallback: function onTrackCallback() {}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
541
552
|
config.users.startAllsenders();
|
|
542
553
|
}
|
|
543
554
|
|
|
544
555
|
if (receivePeerFailed) {
|
|
556
|
+
if (app.sdkParams.callOptions.enableDataChannel) {
|
|
557
|
+
receivePeerFailed && config.receivePeerManager.startDataChannel();
|
|
558
|
+
}
|
|
559
|
+
|
|
545
560
|
Object.values(config.users.getAll()).forEach(function (user) {
|
|
546
561
|
if (!user.isMe()) {
|
|
547
562
|
user.resetTopicVersions();
|
|
@@ -604,8 +619,7 @@ function MultiTrackCallManager(_ref) {
|
|
|
604
619
|
var pc = new RTCPeerConnection({
|
|
605
620
|
iceServers: [turnConfig]
|
|
606
621
|
});
|
|
607
|
-
pc.createDataChannel("test");
|
|
608
|
-
|
|
622
|
+
pc.createDataChannel("test");
|
|
609
623
|
pc.createOffer().then(function (sdp) {
|
|
610
624
|
if (sdp.sdp.indexOf('typ relay') > -1) {
|
|
611
625
|
promiseResolved = true;
|
|
@@ -861,6 +875,12 @@ function MultiTrackCallManager(_ref) {
|
|
|
861
875
|
app.call.callStopQueue.callStarted = true;
|
|
862
876
|
var user = config.users.get(app.store.user.get().id); //Start my own senders
|
|
863
877
|
|
|
878
|
+
if (app.sdkParams.callOptions.enableDataChannel) {
|
|
879
|
+
config.receivePeerManager.startDataChannel();
|
|
880
|
+
config.sendPeerManager.startDataChannel();
|
|
881
|
+
user.startDataChannel();
|
|
882
|
+
}
|
|
883
|
+
|
|
864
884
|
if (user.user().video) {
|
|
865
885
|
user.startVideo(user.user().topicSend, null);
|
|
866
886
|
}
|
|
@@ -1006,25 +1026,28 @@ function MultiTrackCallManager(_ref) {
|
|
|
1006
1026
|
return it.clientId;
|
|
1007
1027
|
}).join(', '), " ||| topics: ").concat(list.map(function (it) {
|
|
1008
1028
|
return it.topic;
|
|
1009
|
-
}).join(', ')));
|
|
1029
|
+
}).join(', ')));
|
|
1010
1030
|
|
|
1011
1031
|
for (var i = list.length - 1; i >= 0; i--) {
|
|
1012
1032
|
if (!processedTopics.includes(list[i].topic)) {
|
|
1013
1033
|
processedTopics.push(list[i].topic);
|
|
1014
|
-
var userId = config.users.findUserIdByTopic(list[i].topic);
|
|
1015
|
-
var user = config.users.get(userId);
|
|
1016
|
-
app.logger.log(app.logger.tags.CALL_PROCESS.id, "[media][RECEIVING_MEDIA][User] ", " clientId: ".concat(list[i].clientId, " , topic: ").concat(list[i].topic, " , item: , ").concat(list[i], ", ").concat({
|
|
1017
|
-
userId: userId,
|
|
1018
|
-
user: user
|
|
1019
|
-
}));
|
|
1020
1034
|
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1023
|
-
|
|
1035
|
+
if (list[i].topic.indexOf("Vi-") > -1 || list[i].topic.indexOf("Vo-") > -1 || list[i].topic.indexOf("data-channel") > -1) {
|
|
1036
|
+
var userId = config.users.findUserIdByTopic(list[i].topic);
|
|
1037
|
+
var user = config.users.get(userId);
|
|
1038
|
+
app.logger.log(app.logger.tags.CALL_PROCESS.id, "[media][RECEIVING_MEDIA][User] ", " clientId: ".concat(list[i].clientId, " , topic: ").concat(list[i].topic, " , item: , ").concat(list[i], ", ").concat({
|
|
1039
|
+
userId: userId,
|
|
1040
|
+
user: user
|
|
1041
|
+
}));
|
|
1042
|
+
|
|
1043
|
+
if (user) {
|
|
1044
|
+
if (user.isScreenShare() && !config.screenShareInfo.iAmOwner() || !user.isMe()) {
|
|
1045
|
+
user.processTrackChange(list[i]);
|
|
1046
|
+
}
|
|
1047
|
+
} else {
|
|
1048
|
+
console.log('[media][RECEIVING_MEDIA] User not found in the call , clientIds: ', list[i]);
|
|
1049
|
+
console.error('[SDK][handleReceivingTracksChanges] User not found in the call. ', list[i]);
|
|
1024
1050
|
}
|
|
1025
|
-
} else {
|
|
1026
|
-
console.log('[media][RECEIVING_MEDIA] User not found in the call , clientIds: ', list[i]);
|
|
1027
|
-
console.error('[SDK][handleReceivingTracksChanges] User not found in the call. ', list[i]);
|
|
1028
1051
|
}
|
|
1029
1052
|
}
|
|
1030
1053
|
}
|
|
@@ -1385,6 +1408,7 @@ function MultiTrackCallManager(_ref) {
|
|
|
1385
1408
|
// config.users.get(userId).appendVideoToCallDiv();
|
|
1386
1409
|
// }
|
|
1387
1410
|
// }
|
|
1411
|
+
config.receivePeerManager.removeRequestTimeout(uniqueId);
|
|
1388
1412
|
config.receivePeerManager && config.receivePeerManager.processingCurrentTrackCompleted(); // config.isReconnecting = false;
|
|
1389
1413
|
// config.receivePeerManager && requestReceivingMedia();
|
|
1390
1414
|
|
|
@@ -2193,6 +2217,10 @@ function MultiTrackCallManager(_ref) {
|
|
|
2193
2217
|
return config.isDestroyed;
|
|
2194
2218
|
};
|
|
2195
2219
|
|
|
2220
|
+
publicized.sendCallData = function (jsonData) {
|
|
2221
|
+
config.sendPeerManager.sendCallData(jsonData);
|
|
2222
|
+
};
|
|
2223
|
+
|
|
2196
2224
|
setTimeout(function () {
|
|
2197
2225
|
startCallWebRTCFunctions(config.callConfig);
|
|
2198
2226
|
}, 50);
|
|
@@ -42,9 +42,16 @@ function CallUser(app, user) {
|
|
|
42
42
|
audio: null
|
|
43
43
|
},
|
|
44
44
|
oldAudioStreamId: null,
|
|
45
|
-
newAudioStreamId: null
|
|
45
|
+
newAudioStreamId: null,
|
|
46
|
+
dataChannelTopicName: null,
|
|
47
|
+
dataChannelIsOpen: false,
|
|
48
|
+
dataChannelReceiveVersion: -1
|
|
46
49
|
};
|
|
50
|
+
config.dataChannelTopicName = "data-channel-".concat(config.callId, "-").concat(config.user.clientId);
|
|
47
51
|
var publicized = {
|
|
52
|
+
getDataChannelTopicName: function getDataChannelTopicName() {
|
|
53
|
+
return config.dataChannelTopicName;
|
|
54
|
+
},
|
|
48
55
|
getAudioStream: function getAudioStream() {
|
|
49
56
|
return config.audioStream;
|
|
50
57
|
},
|
|
@@ -83,6 +90,7 @@ function CallUser(app, user) {
|
|
|
83
90
|
resetTopicVersions: function resetTopicVersions() {
|
|
84
91
|
config.videoReceiveVersion = -1;
|
|
85
92
|
config.audioReceiveVersion = -1;
|
|
93
|
+
config.dataChannelReceiveVersion = -1;
|
|
86
94
|
},
|
|
87
95
|
getAudioObject: function getAudioObject() {
|
|
88
96
|
return config.audioObject;
|
|
@@ -578,6 +586,23 @@ function CallUser(app, user) {
|
|
|
578
586
|
}, _callee8);
|
|
579
587
|
}))();
|
|
580
588
|
},
|
|
589
|
+
startDataChannel: function startDataChannel(conf) {
|
|
590
|
+
if (config.isMe) {
|
|
591
|
+
config.dataChannelIsOpen = true;
|
|
592
|
+
config.dataChannelTopicName = "data-channel-".concat(config.callId, "-").concat(config.user.clientId);
|
|
593
|
+
addSendTrackToPeerManager('dataChannel');
|
|
594
|
+
} else {
|
|
595
|
+
config.dataChannelIsOpen = true;
|
|
596
|
+
config.dataChannelReceiveVersion = conf.version;
|
|
597
|
+
config.dataChannelTopicName = conf.topic;
|
|
598
|
+
addReceiveTrackToPeerManager('dataChannel', conf);
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
stopDataChannel: function stopDataChannel() {
|
|
602
|
+
config.dataChannelReceiveVersion = -1;
|
|
603
|
+
config.dataChannelIsOpen = false;
|
|
604
|
+
app.call.currentCall().receivePeerManager().removeDataChannel(config.dataChannelTopicName);
|
|
605
|
+
},
|
|
581
606
|
getReceiveVideoVersion: function getReceiveVideoVersion() {
|
|
582
607
|
return config.videoReceiveVersion;
|
|
583
608
|
},
|
|
@@ -585,7 +610,18 @@ function CallUser(app, user) {
|
|
|
585
610
|
return config.audioReceiveVersion;
|
|
586
611
|
},
|
|
587
612
|
processTrackChange: function processTrackChange(conf) {
|
|
588
|
-
if (conf.topic.indexOf('
|
|
613
|
+
if (conf.topic.indexOf('data-channel') > -1) {
|
|
614
|
+
if (!config.dataChannelIsOpen && conf.isReceiving) {
|
|
615
|
+
publicized.startDataChannel(conf);
|
|
616
|
+
} else if (config.dataChannelIsOpen && !conf.isReceiving) {
|
|
617
|
+
publicized.stopDataChannel();
|
|
618
|
+
} else if (config.dataChannelIsOpen && conf.isReceiving && config.dataChannelReceiveVersion != conf.version) {
|
|
619
|
+
publicized.stopDataChannel();
|
|
620
|
+
setTimeout(function () {
|
|
621
|
+
publicized.startDataChannel(conf);
|
|
622
|
+
}, 200);
|
|
623
|
+
}
|
|
624
|
+
} else if (conf.topic.indexOf('Vi-') > -1) {
|
|
589
625
|
if (!config.videoIsOpen && conf.isReceiving) {
|
|
590
626
|
publicized.startVideo(conf.topic.replace('Vi-', ''), conf);
|
|
591
627
|
} else if (config.videoIsOpen && !conf.isReceiving) {
|
|
@@ -702,7 +738,14 @@ function CallUser(app, user) {
|
|
|
702
738
|
|
|
703
739
|
var addRes;
|
|
704
740
|
|
|
705
|
-
if (media == '
|
|
741
|
+
if (media == 'dataChannel') {
|
|
742
|
+
addRes = app.call.currentCall().sendPeerManager().addTrack({
|
|
743
|
+
topic: config.dataChannelTopicName,
|
|
744
|
+
mediaType: 3,
|
|
745
|
+
clientId: config.user.clientId,
|
|
746
|
+
onTrackCallback: function onTrackCallback() {}
|
|
747
|
+
});
|
|
748
|
+
} else if (media == 'video') {
|
|
706
749
|
var stream = app.call.deviceManager.mediaStreams.getVideoInput();
|
|
707
750
|
addRes = app.call.currentCall().sendPeerManager().addTrack({
|
|
708
751
|
currentTrackId: stream.getTracks()[0].id,
|
|
@@ -747,7 +790,15 @@ function CallUser(app, user) {
|
|
|
747
790
|
|
|
748
791
|
var addRes;
|
|
749
792
|
|
|
750
|
-
if (media == '
|
|
793
|
+
if (media == 'dataChannel') {
|
|
794
|
+
addRes = app.call.currentCall().receivePeerManager().addTrack({
|
|
795
|
+
topic: conf.topic,
|
|
796
|
+
mediaType: 3,
|
|
797
|
+
clientId: config.user.clientId,
|
|
798
|
+
onTrackCallback: function onTrackCallback() {},
|
|
799
|
+
onUpdateSuccess: function onUpdateSuccess() {}
|
|
800
|
+
});
|
|
801
|
+
} else if (media == 'video') {
|
|
751
802
|
addRes = app.call.currentCall().receivePeerManager().addTrack({
|
|
752
803
|
clientId: config.user.clientId,
|
|
753
804
|
topic: config.user.videoTopicName,
|
|
@@ -135,6 +135,10 @@ function CallUsers(_ref) {
|
|
|
135
135
|
},
|
|
136
136
|
findUserIdByTopic: function findUserIdByTopic(topic) {
|
|
137
137
|
for (var i in config.list) {
|
|
138
|
+
if (config.list[i] && config.list[i].getDataChannelTopicName() === topic) {
|
|
139
|
+
return i;
|
|
140
|
+
}
|
|
141
|
+
|
|
138
142
|
if (config.list[i] && (config.list[i].user().videoTopicName === topic || config.list[i].user().audioTopicName === topic) || topic.indexOf('screen') > -1 && i == 'screenShare') {
|
|
139
143
|
return i;
|
|
140
144
|
}
|
|
@@ -9,6 +9,8 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
12
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
15
|
|
|
14
16
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -78,6 +80,9 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
78
80
|
this._midManager = new _midManager["default"]({
|
|
79
81
|
app: app
|
|
80
82
|
});
|
|
83
|
+
this._datachannel = null;
|
|
84
|
+
this._receiveDatachannel = null;
|
|
85
|
+
this._receiveDatachannels = [];
|
|
81
86
|
var that = this;
|
|
82
87
|
|
|
83
88
|
window.trackList = function () {
|
|
@@ -143,35 +148,37 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
143
148
|
uuid = _utility["default"].generateUUID();
|
|
144
149
|
|
|
145
150
|
item.uniqueId = uuid;
|
|
151
|
+
var localStream;
|
|
146
152
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
if (item.mediaType !== 3) {
|
|
154
|
+
//dataChannel
|
|
155
|
+
var sender = this._peer.peerConnection.getSenders().find(function (s, index) {
|
|
156
|
+
if (s.track == item.stream.getTracks()[0]) {
|
|
157
|
+
localTrackIndex = index;
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
if (sender) {
|
|
163
|
+
console.warn('Track already exists in connection, direction: send'); // item.onTrackCallback(item, item.stream.getTracks()[localTrackIndex])
|
|
164
|
+
}
|
|
157
165
|
|
|
158
|
-
|
|
166
|
+
if (item.topic.indexOf('Vi-') > -1 || item.topic.indexOf('screen') > -1) {
|
|
167
|
+
if (item.isScreenShare) {
|
|
168
|
+
localStream = this._app.call.deviceManager.mediaStreams.getScreenShareInput();
|
|
169
|
+
} else {
|
|
170
|
+
localStream = this._app.call.deviceManager.mediaStreams.getVideoInput();
|
|
171
|
+
}
|
|
159
172
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
if (localStream && !sender) {
|
|
174
|
+
this._peer.addTrack(localStream.getTracks()[0], localStream);
|
|
175
|
+
}
|
|
163
176
|
} else {
|
|
164
|
-
localStream = this._app.call.deviceManager.mediaStreams.
|
|
165
|
-
}
|
|
177
|
+
localStream = this._app.call.deviceManager.mediaStreams.getAudioInput();
|
|
166
178
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
} else {
|
|
171
|
-
localStream = this._app.call.deviceManager.mediaStreams.getAudioInput();
|
|
172
|
-
|
|
173
|
-
if (localStream && !sender) {
|
|
174
|
-
this._peer.addTrack(localStream.getTracks()[0], localStream);
|
|
179
|
+
if (localStream && !sender) {
|
|
180
|
+
this._peer.addTrack(localStream.getTracks()[0], localStream);
|
|
181
|
+
}
|
|
175
182
|
}
|
|
176
183
|
}
|
|
177
184
|
|
|
@@ -188,7 +195,9 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
188
195
|
}, null, {});
|
|
189
196
|
};
|
|
190
197
|
|
|
191
|
-
item.
|
|
198
|
+
if (item.mediaType !== 3) {
|
|
199
|
+
item.onTrackCallback(item, localStream.getTracks()[0]);
|
|
200
|
+
}
|
|
192
201
|
|
|
193
202
|
if (this._firstSub) {
|
|
194
203
|
this._firstSub = false;
|
|
@@ -595,6 +604,19 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
595
604
|
}
|
|
596
605
|
}
|
|
597
606
|
}, {
|
|
607
|
+
key: "removeDataChannel",
|
|
608
|
+
value: function removeDataChannel(topic) {
|
|
609
|
+
var item = this._trackList.find(function (it) {
|
|
610
|
+
return it && it.topic === topic;
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
if (item) {
|
|
614
|
+
this._trackList = this._trackList.filter(function (it) {
|
|
615
|
+
return it.topic != item.topic;
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}, {
|
|
598
620
|
key: "processingCurrentTrackCompleted",
|
|
599
621
|
value: function processingCurrentTrackCompleted() {
|
|
600
622
|
if (this._direction == 'send') this._addTrackQueue.shift();
|
|
@@ -926,6 +948,8 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
926
948
|
topics.forEach(function (it) {
|
|
927
949
|
if (item.topic == it.topic) {
|
|
928
950
|
timeoutsList[it.topic] = setTimeout(function () {
|
|
951
|
+
if (!_this11._app.call.currentCall()) return;
|
|
952
|
+
|
|
929
953
|
var uId = _this11._app.call.currentCall().users().findUserIdByTopic(it.topic);
|
|
930
954
|
|
|
931
955
|
if (!uId) return; // this._app.call.currentCall().users().get(uId).trackOpenQueue.add();
|
|
@@ -1351,6 +1375,107 @@ var PeerConnectionManager = /*#__PURE__*/function () {
|
|
|
1351
1375
|
value: function getPeerStatus() {
|
|
1352
1376
|
if (this.isPeerConnected()) return 'connected';else if (this.isPeerFailed()) return 'failed';else if (this.isPeerConnecting()) return 'connecting';else if (this.isPeerDisconnected()) return 'disconnected';
|
|
1353
1377
|
}
|
|
1378
|
+
}, {
|
|
1379
|
+
key: "startDataChannel",
|
|
1380
|
+
value: function startDataChannel() {
|
|
1381
|
+
var _this17 = this;
|
|
1382
|
+
|
|
1383
|
+
if (this._datachannel) return;
|
|
1384
|
+
|
|
1385
|
+
if (this._direction === "send") {
|
|
1386
|
+
this._datachannel = this._peer.peerConnection.createDataChannel("JanusDataChannel", {
|
|
1387
|
+
ordered: true
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
this._datachannel.onopen = function (event) {
|
|
1391
|
+
// let label = event.target.label,
|
|
1392
|
+
//protocol = event.target.protocol,
|
|
1393
|
+
//dcState = this.dataChannel[label] ? this.dataChannel[label].readyState : "null";
|
|
1394
|
+
// if (dcState === 'open') {
|
|
1395
|
+
// // Any pending messages to send?
|
|
1396
|
+
// if (this.dataChannel[label].pending && this.dataChannel[label].pending.length > 0) {
|
|
1397
|
+
// for (let data of this.dataChannel[label].pending) {
|
|
1398
|
+
// this.dataChannel[label].send(data);
|
|
1399
|
+
// }
|
|
1400
|
+
// this.dataChannel[label].pending = [];
|
|
1401
|
+
// }
|
|
1402
|
+
// }
|
|
1403
|
+
_this17._app.call.currentCall().sendCallMessage({
|
|
1404
|
+
id: "DATA_CHANNEL_OPENED",
|
|
1405
|
+
token: _this17._app.sdkParams.token,
|
|
1406
|
+
chatId: _this17._callId,
|
|
1407
|
+
clientId: _this17._app.call.currentCall().users().get(_this17._app.store.user.get().id).user().clientId
|
|
1408
|
+
}, null, {});
|
|
1409
|
+
|
|
1410
|
+
console.log("[SDK][CallChannel] Opened ".concat(_this17._direction === "send" ? "Send" : "Receive", "DataChannel"));
|
|
1411
|
+
};
|
|
1412
|
+
} else {
|
|
1413
|
+
var _that = this;
|
|
1414
|
+
|
|
1415
|
+
this._receiveDatachannel = this._peer.peerConnection.createDataChannel("JanusDataChannel", {
|
|
1416
|
+
ordered: true
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
this._peer.peerConnection.ondatachannel = function (event) {
|
|
1420
|
+
var label = event.target.label,
|
|
1421
|
+
protocol = event.target.protocol,
|
|
1422
|
+
dcState = _this17._receiveDatachannels[label] ? _this17._receiveDatachannels[label].readyState : null; // if(this._receiveDatachannels[label]) {
|
|
1423
|
+
// return;
|
|
1424
|
+
// }
|
|
1425
|
+
|
|
1426
|
+
_that._receiveDatachannels[label] = event.channel;
|
|
1427
|
+
|
|
1428
|
+
_that._receiveDatachannels[label].onopen = function (event) {
|
|
1429
|
+
console.log("[SDK][CallChannel] onopen ".concat(_this17._direction === "send" ? "Send" : "Receive", "DataChannel"), {
|
|
1430
|
+
event: event
|
|
1431
|
+
});
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
_that._receiveDatachannels[label].onmessage = function (event) {
|
|
1435
|
+
_that._app.chatEvents.fireEvent('callEvents', {
|
|
1436
|
+
type: 'CALL_DATA',
|
|
1437
|
+
callId: _this17._callId,
|
|
1438
|
+
result: event
|
|
1439
|
+
});
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1442
|
+
_that._receiveDatachannels[label].onerror = function (event) {
|
|
1443
|
+
console.log("[SDK][CallChannel] OnError ".concat(_this17._direction === "send" ? "Send" : "Receive", "DataChannel"), {
|
|
1444
|
+
event: event
|
|
1445
|
+
});
|
|
1446
|
+
};
|
|
1447
|
+
|
|
1448
|
+
_that._receiveDatachannels[label].onclose = function (event) {
|
|
1449
|
+
console.log("[SDK][CallChannel] OnClose ".concat(_this17._direction === "send" ? "Send" : "Receive", "DataChannel"), {
|
|
1450
|
+
event: event
|
|
1451
|
+
});
|
|
1452
|
+
};
|
|
1453
|
+
}; // that.dataChannel.onmessage = (data) => {
|
|
1454
|
+
// console.log(`onmessage ${(that._direction === "send" ? "Send" : "Receive")}DataChannel`, {data});
|
|
1455
|
+
// }
|
|
1456
|
+
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}, {
|
|
1460
|
+
key: "sendCallData",
|
|
1461
|
+
value: function sendCallData(data) {
|
|
1462
|
+
var sendData = data;
|
|
1463
|
+
|
|
1464
|
+
if ((0, _typeof2["default"])(data) == "object") {
|
|
1465
|
+
sendData = JSON.stringify(data);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
if (!this._datachannel || this._datachannel.readyState != 'open') {
|
|
1469
|
+
this._app.errorHandler.raiseError({
|
|
1470
|
+
code: _errorHandler.errorList.DATACHANNEL_NOT_READY.code,
|
|
1471
|
+
message: _errorHandler.errorList.DATACHANNEL_NOT_READY.message
|
|
1472
|
+
}, null, true, {});
|
|
1473
|
+
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
this._datachannel.send(sendData);
|
|
1478
|
+
}
|
|
1354
1479
|
}, {
|
|
1355
1480
|
key: "resetSendQueue",
|
|
1356
1481
|
value: function resetSendQueue() {
|
|
@@ -191,6 +191,30 @@ function ThreadHistoryMethods(app) {
|
|
|
191
191
|
uniqueId: sendMessageParams.uniqueId
|
|
192
192
|
},
|
|
193
193
|
res = app.store.history.get(params.threadId).getCacheData(sendMessageParams.content, timeMiliSeconds);
|
|
194
|
+
|
|
195
|
+
if (params.returnOriginalData) {
|
|
196
|
+
res = JSON.parse(JSON.stringify(res));
|
|
197
|
+
res.reverse();
|
|
198
|
+
res.forEach(function (item) {
|
|
199
|
+
if (item.time) {
|
|
200
|
+
item.timeFull = item.time;
|
|
201
|
+
item.time = item.timeMiliSeconds;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (item.callHistory) {
|
|
205
|
+
item.callHistoryVO = item.callHistory;
|
|
206
|
+
delete item.callHistory;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (item.replyInfo) {
|
|
210
|
+
item.replyInfoVO = item.replyInfo;
|
|
211
|
+
delete item.replyInfo;
|
|
212
|
+
item.replyInfoVO.repliedToMessageTimeFull = item.replyInfoVO.repliedToMessageTime;
|
|
213
|
+
item.replyInfoVO.repliedToMessageTime = item.replyInfoVO.repliedToMessageTimeMiliSeconds;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
194
218
|
retrnData.result = {
|
|
195
219
|
history: res,
|
|
196
220
|
hasNext: !(res.length < params.count),
|
|
@@ -168,7 +168,7 @@ function ThreadMethods(app) {
|
|
|
168
168
|
*/
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
function createThread(messageContent, addFromService, showThread) {
|
|
171
|
+
function createThread(messageContent, addFromService, showThread, uniqueId) {
|
|
172
172
|
var threadData = (0, _dataFormatters.formatDataToMakeConversation)(messageContent);
|
|
173
173
|
var redirectToThread = showThread === true ? showThread : false;
|
|
174
174
|
|
|
@@ -178,7 +178,8 @@ function ThreadMethods(app) {
|
|
|
178
178
|
redirectToThread: redirectToThread,
|
|
179
179
|
result: {
|
|
180
180
|
thread: threadData
|
|
181
|
-
}
|
|
181
|
+
},
|
|
182
|
+
uniqueId: uniqueId
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -242,9 +243,8 @@ function ThreadMethods(app) {
|
|
|
242
243
|
|
|
243
244
|
if (parseInt(params.toTime) > 0 && parseInt(params.toTime) < 9999999999999) {
|
|
244
245
|
content.toTime = parseInt(params.toTime);
|
|
245
|
-
}
|
|
246
|
+
} //var functionLevelCache = (typeof params.cache == 'boolean') ? params.cache : true;
|
|
246
247
|
|
|
247
|
-
var functionLevelCache = typeof params.cache == 'boolean' ? params.cache : true;
|
|
248
248
|
|
|
249
249
|
if (typeof params.isGroup === 'boolean') {
|
|
250
250
|
content.isGroup = params.isGroup;
|
|
@@ -270,7 +270,19 @@ function ThreadMethods(app) {
|
|
|
270
270
|
var threadCache = app.store.thread.getCacheData(params);
|
|
271
271
|
|
|
272
272
|
if (threadCache) {
|
|
273
|
-
|
|
273
|
+
var returnData = threadCache;
|
|
274
|
+
|
|
275
|
+
if (params.returnOriginalData) {
|
|
276
|
+
returnData = JSON.parse(JSON.stringify(threadCache));
|
|
277
|
+
returnData.result.threads.forEach(function (item) {
|
|
278
|
+
if (item.lastMessageVO && item.lastMessageVO.time) {
|
|
279
|
+
item.lastMessageVO.timeFull = item.lastMessageVO.time;
|
|
280
|
+
item.lastMessageVO.time = item.lastMessageVO.timeMiliSeconds;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
callback && callback(returnData);
|
|
274
286
|
callback = undefined;
|
|
275
287
|
return;
|
|
276
288
|
}
|
|
@@ -310,7 +322,7 @@ function ThreadMethods(app) {
|
|
|
310
322
|
threadData;
|
|
311
323
|
|
|
312
324
|
for (var i = 0; i < messageLength; i++) {
|
|
313
|
-
threadData = app.threadMethods.createThread(messageContent[i], false);
|
|
325
|
+
threadData = app.threadMethods.createThread(messageContent[i], false, false);
|
|
314
326
|
|
|
315
327
|
if (threadData) {
|
|
316
328
|
resultData.threads.push(threadData);
|
|
@@ -354,10 +366,10 @@ function ThreadMethods(app) {
|
|
|
354
366
|
messageContent.uniqueId = uniqueId;
|
|
355
367
|
|
|
356
368
|
if (app.store.messagesCallbacks[uniqueId]) {
|
|
357
|
-
app.threadMethods.createThread(messageContent, true, true);
|
|
358
|
-
app.store.messagesCallbacks[uniqueId](_utility["default"].createReturnData(chatMessage.typeCode, chatMessage.ownerId, false, '', 0, messageContent, contentCount));
|
|
369
|
+
app.threadMethods.createThread(messageContent, true, true, uniqueId);
|
|
370
|
+
app.store.messagesCallbacks[uniqueId](_utility["default"].createReturnData(chatMessage.typeCode, chatMessage.ownerId, false, '', 0, messageContent, contentCount, uniqueId));
|
|
359
371
|
} else {
|
|
360
|
-
app.threadMethods.createThread(messageContent, true, false);
|
|
372
|
+
app.threadMethods.createThread(messageContent, true, false, uniqueId);
|
|
361
373
|
}
|
|
362
374
|
|
|
363
375
|
var threadData = (0, _dataFormatters.formatDataToMakeConversation)(messageContent);
|
|
@@ -46,6 +46,11 @@ var errorList = {
|
|
|
46
46
|
message: "[SDK] Parameter {parameterName} value is not valid.",
|
|
47
47
|
variables: ['{parameterName}']
|
|
48
48
|
},
|
|
49
|
+
ONLY_OBJECT_IS_ALLOWED: {
|
|
50
|
+
code: 12008,
|
|
51
|
+
message: "[SDK] Parameter {parameterName} in method {methodName} must be an {parameterType}}.",
|
|
52
|
+
variables: ['{parameterName}', '{methodName}', '{parameterType}']
|
|
53
|
+
},
|
|
49
54
|
|
|
50
55
|
/**
|
|
51
56
|
* 12350-12399
|
|
@@ -166,6 +171,14 @@ var errorList = {
|
|
|
166
171
|
TURN_SERVERS_NOT_ACCESSIBLE: {
|
|
167
172
|
code: 12756,
|
|
168
173
|
message: "[SDK] Check turn server failed. Try changing your network."
|
|
174
|
+
},
|
|
175
|
+
DATACHANNEL_NOT_ENABLED: {
|
|
176
|
+
code: 12757,
|
|
177
|
+
message: "[SDK] DataChannel is not enabled in calloptions."
|
|
178
|
+
},
|
|
179
|
+
DATACHANNEL_NOT_READY: {
|
|
180
|
+
code: 12758,
|
|
181
|
+
message: "[SDK] DataChannel is not ready, retry later."
|
|
169
182
|
}
|
|
170
183
|
};
|
|
171
184
|
exports.errorList = errorList;
|