第二台设备无法进行视频通话

时间:2014-03-28 23:23:33

标签: ios iphone objective-c cocoa-touch quickblox

我正在使用QuickBlox从一台设备到另一台设备进行视频通话。 这是我拨打电话的设备上的代码:

viewDidLoad

- (void)viewDidLoad {
    [super viewDidLoad];

    self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstance];
    self.videoChat.viewToRenderOpponentVideoStream = self.otherUserView;
    self.videoChat.viewToRenderOwnVideoStream = self.selfView;

    QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
    extendedAuthRequest.userLogin = USERNAME 
    extendedAuthRequest.userPassword = PASSWORD
    [QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];

}

创建会话

#pragma mark - QBActionStatusDelegate

- (void)completedWithResult:(Result *)result{
    if(result.success && [result isKindOfClass:QBAAuthSessionCreationResult.class]){
        // Success, You have got User session

        QBAAuthSessionCreationResult *res = (QBAAuthSessionCreationResult *)result;

        QBUUser *currentUser = [QBUUser user];
        currentUser.ID = res.session.userID;
        currentUser.password = PASSWORD

        // set Chat delegate
        [QBChat instance].delegate = self;

        // login to Chat
        [[QBChat instance] loginWithUser:currentUser];
    }
}

登录聊天

(void) chatDidLogin {
    // You have successfully signed in to QuickBlox Chat
    [NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:@selector(sendPresence) userInfo:nil repeats:YES];
}

拨打电话:

- (IBAction)callUser:(id)sender {


    [QBChat instance].delegate = self;
    [self.videoChat callUser:USERID conferenceType:QBVideoChatConferenceTypeAudioAndVideo];
}

接听电话

我已经检查过了。用户登录聊天,我试图呼叫的ID是正确的,另一个用户也登录聊天,但这永远不会被调用:

-(void) chatDidReceiveCallRequestFromUser:(NSUInteger)userID withSessionID:(NSString *)_sessionID conferenceType:(enum QBVideoChatConferenceType)conferenceType {
    self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstanceWithSessionID:_sessionID];
    //
    [self.videoChat acceptCallWithOpponentID:userID conferenceType:conferenceType];


}

1 个答案:

答案 0 :(得分:0)

所以答案就是,我过早地创建了QBVideoChat对象。我登录聊天后最终创建了它

-(void) chatDidLogin {
    // You have successfully signed in to QuickBlox Chat
    [NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:@selector(sendPresence) userInfo:nil repeats:YES];

    self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstance];
    self.videoChat.viewToRenderOpponentVideoStream = self.otherUserView;
    self.videoChat.viewToRenderOwnVideoStream = self.selfView;
 }