ID为X的QBWebRTC此时正忙? QB.webrtc.onRemoteStreamListener未触发。 Quickblox Javascript SDK + angular + WebRTC
问题描述:
我已经跟随了三次文档,我无法接受电话。下面是代码:ID为X的QBWebRTC此时正忙? QB.webrtc.onRemoteStreamListener未触发。 Quickblox Javascript SDK + angular + WebRTC
$scope.occupants = [6184, 6186];
$scope.session = QB.webrtc.createNewSession($scope.occupants, QB.webrtc.CallType.VIDEO);
$scope.localMediaParams = {
audio: true,
video: true,
options: {
muted: true,
mirror: true
},
elemId: 'localVideoEl',
optional: {
minWidth: 240,
maxWidth: 320,
minHeight: 160,
maxHeight: 240
}
};
$scope.startCall = function() {
if (angular.equals($scope.recipients, {})) {
alert('Please choose a person to call');
}else {
if (angular.equals($scope.session, {})) {
console.log('session hasn\'t been started');
$scope.session.stop({});
$scope.session = {};
return false;
}else {
$scope.session.getUserMedia($scope.localMediaParams, function(err, stream) {
if (err){
console.log(err);
}else{
console.log(stream);
$scope.session.call({}, function(error) {
console.log(error);
});
}
});
}
}
};
$scope.answerCall = function() {
$scope.session.getUserMedia($scope.localMediaParams, function(err, stream) {
if (err){
console.log(err);
$scope.session.stop({});
}else{
console.log(stream);
$scope.session.accept({});
}
});
};
QB.webrtc.onRemoteStreamListener = function(session, userID, remoteStream) {
// attach the remote stream to DOM element
console.log('onRemoteStreamListener');
console.log($scope.session);
$scope.session.attachMediaStream('remoteVideoEl', remoteStream);
};
我有两个用户ID的6184和6186.我开始从用户6186的呼叫,并在控制台显示此:
[QBWebRTC]: RTCPeerConnection init. userID: 6186, sessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e, type: offer
telemed.js:432 null
quickblox.min.js:86149 [QBWebRTC]: getAndSetLocalSessionDescription success
quickblox.min.js:86149 [QBWebRTC]: _startDialingTimer, dialingTimeInterval: 5000
quickblox.min.js:86149 [QBWebRTC]: _dialingCallback, answerTimeInterval: 0
quickblox.min.js:86149 [QBWebRTC]: getAndSetLocalSessionDescription success
quickblox.min.js:86149 [QBWebRTC]: _startDialingTimer, dialingTimeInterval: 5000
quickblox.min.js:86149 [QBWebRTC]: _dialingCallback, answerTimeInterval: 0
quickblox.min.js:86149 [QBWebRTC]: onCall. UserID:6186. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
quickblox.min.js:86149 [QBWebRTC]: onReject. UserID:6184. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
quickblox.min.js:86149 [QBWebRTC]: _clearDialingTimer
quickblox.min.js:86149 [QBWebRTC]: All peer connections closed: false
quickblox.min.js:86149 [QBWebRTC]: onIceConnectionStateCallback: closed
quickblox.min.js:86149 [QBWebRTC]: _dialingCallback, answerTimeInterval: 5000
quickblox.min.js:86149 [QBWebRTC]: onCall. UserID:6186. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
quickblox.min.js:86149 [QBWebRTC]: Stop, extension: {}
quickblox.min.js:86149 [QBWebRTC]: _close
quickblox.min.js:86149 [QBWebRTC]: _clearDialingTimer
quickblox.min.js:86149 [QBWebRTC]: onIceConnectionStateCallback: closed
现在的anwering边我看到产生一个呼叫,但随后说,发起呼叫者忙:
[QBWebRTC]: onCall. UserID:6186. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
quickblox.min.js:86149 [QBWebRTC]: User with id 6186 is busy at the moment.
quickblox.min.js:86149 [QBWebRTC]: onStop. UserID:6186. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
谁能告诉我是怎么回事就在这里,为什么QB.webrtc.onRemoteStreamListener不火的应答侧?
一两件事:
我打完电话后,我得到这个错误,我也搞不懂,因为它也有坏英语:
[QBWebRTC]: onStop. UserID:6186. SessionID: 7e7ea17c-a207-4af0-82e1-744fbcce830e
quickblox.min.js:86161 [QBWebRTC]: Ignore 'onStop', there is no information about session 7e7ea17c-a207-4af0-82e1-744fbcce830e by some reason.
答
我无法接受呼叫的原因是,我是不重视从QB.webrtc.onCallListener监听流。
QB.webrtc.onCallListener = function(session, extension) {
$scope.session = session;
console.log('User '+session.currentUserID+' is calling');
};
的文档没有解释什么用户需要的乘客阵列,以及你应该随大流做什么,一旦它击中的是听众。从角度来看,你应该得到一个$ scope.session,或者如果你没有将QB.webrtc.onCallListener流附加到会话或$ scope.session对象中,会话是未定义的。另外,正如Igor指出的那样,您不应该将用户ID包含在占用者数组中。
答
我开始从通话用户6186和控制台
你不必列出当前用户的ID在乘客:
所以不是
$scope.occupants = [6184, 6186];
你应该使用
$scope.occupants = [6184];