主頁(yè) > 服務(wù)與支持 > 開(kāi)發(fā)平臺(tái) > 客戶端SDK參考 > iOS Native SDK > 會(huì)議 網(wǎng)絡(luò)變化時(shí)恢復(fù)會(huì)議
更新時(shí)間:2019-11-20
描述
用戶正在會(huì)議中,用戶設(shè)備的網(wǎng)絡(luò)發(fā)生變化時(shí),應(yīng)用程序可以自動(dòng)恢復(fù)會(huì)議連接。
前提條件
用戶正在會(huì)議中,應(yīng)用程序檢測(cè)到IP地址變化。
業(yè)務(wù)流程
若應(yīng)用程序期望SDK嘗試以最大能力自動(dòng)恢復(fù),需要將參數(shù)TSDK_S_LOCAL_ADDRESS結(jié)構(gòu)中 is_try_resume 設(shè)置為T(mén)SDK_TRUE。
代碼示例:
//oc code -(void)networkStatusChangeNotify:(NSNotification *)notify { NetworkStatus netStatus = (NetworkStatus)[[notify object] integerValue]; if (netStatus == ECSNotReachable) { if (!_isJoinConfCall) { [[ManagerService callService] hangupAllCall]; [self showMessage:@"Current network is unavailable"]; } } NSString *ip = [CommonUtils getLocalIpAddressWithIsVPN:[CommonUtils checkIsVPNConnect]]; if ([ip isEqualToString:@"0.0.0.0"]) { [[ECSDKProgressHud shareInstance] makeProgressHUD:@"the network is disconnected" duration:2.0]; } if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { return; } if (![LoginCenter sharedInstance].isResuming) { //config local ip TSDK_S_LOCAL_ADDRESS local_ip; memset(&local_ip, 0, sizeof(TSDK_S_LOCAL_ADDRESS)); strcpy(local_ip.ip_address, [ip UTF8String]); local_ip.is_try_resume = TSDK_TRUE; TSDK_RESULT configResult = tsdk_set_config_param(TSDK_E_CONFIG_LOCAL_ADDRESS, &local_ip); DDLogInfo(@"config local address result: %d; local ip is: %@", configResult, ip); }else{ _needSetLocalIp = YES; } }
若不在會(huì)議中,則僅進(jìn)行嘗試恢復(fù)登錄處理。
代碼示例:
//oc code case TSDK_E_CONF_EVT_CONF_RESUMING_IND: { self.hasConfResumedFirstRewatch = YES; [self confStopReplay]; dispatch_async(dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:LOGIN_AND_CONF_RESUMING_NOTIFY object:nil]; }); } break;
若在會(huì)議中,建議應(yīng)用程序僅提示“會(huì)議正在恢復(fù)中”。
代碼示例:
//oc code - (void) showResumeNotify { if (_isJoinConfCall) { [[ECSDKProgressHud shareInstance] makeProgressHUD:@"Poor network quality. Attempting to join the meeting again..." duration:4.0]; }else{ [[ECSDKProgressHud shareInstance] makeProgressHUD:@"Poor network quality. Attempting to login again..." duration:4.0]; } }
登錄狀態(tài)恢復(fù)過(guò)程中,SDK上報(bào)的過(guò)程事件通知與普通登錄處理相同?;謴?fù)過(guò)程若出現(xiàn)異常,則通過(guò)
TSDK_E_LOGIN_EVT_LOGIN_RESUME_RESULT上報(bào)原因。只有登錄恢復(fù)成功,SDK才會(huì)進(jìn)行會(huì)議恢復(fù)處理。
代碼示例:
//oc code case TSDK_E_CONF_EVT_CONF_RESUME_RESULT: { DDLogInfo(@"TSDK_E_CONF_EVT_CONF_RESUME_RESULT"); BOOL result = notify.param2 == TSDK_SUCCESS; if (!result) { DDLogError(@"TSDK_E_CONF_EVT_JOIN_CONF_RESULT,error:%@",[NSString stringWithUTF8String:(TSDK_CHAR *)notify.data]); [self restoreConfParamsInitialValue]; return; } _confHandle = notify.param1; TSDK_S_RESUME_CONF_IND_INFO *confResumeInfo = (TSDK_S_RESUME_CONF_IND_INFO *)notify.data; TSDK_S_JOIN_CONF_IND_INFO* confInfo = (TSDK_S_JOIN_CONF_IND_INFO *)&confResumeInfo->join_conf_ind_info; self.currentCallId = confInfo->call_id; if (self.currentJoinConfIndInfo == nil) { self.currentJoinConfIndInfo = [[JoinConfIndInfo alloc] init]; } self.currentJoinConfIndInfo.callId = confInfo->call_id; self.currentJoinConfIndInfo.confMediaType = confInfo->conf_media_type; self.currentJoinConfIndInfo.isHdConf = confInfo->is_hd_conf; self.currentJoinConfIndInfo.confEnvType = confInfo->conf_env_type; self.currentJoinConfIndInfo.isSvcConf = confInfo->is_svc_conf; self.currentJoinConfIndInfo.svcLableCount = confInfo->svc_label_count; NSMutableArray *lableArray = [[NSMutableArray alloc] init]; TSDK_UINT32 *svc_lable = confInfo->svc_label; for (int i = 0; i <= self.currentJoinConfIndInfo.svcLableCount; i++) { TSDK_UINT32 lable = svc_lable[i]; [lableArray addObject:[NSNumber numberWithInt:lable]]; } self.currentJoinConfIndInfo.svcLable = [NSArray arrayWithArray:lableArray]; if (confInfo->conf_media_type == TSDK_E_CONF_MEDIA_VIDEO || confInfo->conf_media_type == TSDK_E_CONF_MEDIA_VIDEO_DATA) { self.isVideoConfInvited = YES; } [self respondsECConferenceDelegateWithType:CONF_E_CONNECT result:nil]; dispatch_async(dispatch_get_main_queue(), ^{ // go conference DDLogInfo(@"goConferenceRunView"); [[NSNotificationCenter defaultCenter] postNotificationName:TUP_CALL_REMOVE_CALL_VIEW_NOTIFY object:nil]; }); } break;
注意事項(xiàng)
若SDK在首次上報(bào)TSDK_E_CONF_EVT_CONF_RESUMING_IND事件60秒內(nèi),未正常恢復(fù)會(huì)議,SDK會(huì)自動(dòng)放棄恢復(fù)。