更新时间:2019-11-20
描述
用户正在会议中,用户设备的网络发生变化时,应用程序可以自动恢复会议连接。
前提条件
用户正在会议中,应用程序检测到IP地址变化。
业务流程
若应用程序期望SDK尝试以最大能力自动恢复,需要将参数TSDK_S_LOCAL_ADDRESS结构中 is_try_resume 设置为TSDK_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; } }
若不在会议中,则仅进行尝试恢复登录处理。
代码示例:
//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;
若在会议中,建议应用程序仅提示“会议正在恢复中”。
代码示例:
//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]; } }
登录状态恢复过程中,SDK上报的过程事件通知与普通登录处理相同。恢复过程若出现异常,则通过
TSDK_E_LOGIN_EVT_LOGIN_RESUME_RESULT上报原因。只有登录恢复成功,SDK才会进行会议恢复处理。
代码示例:
//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;
注意事项
若SDK在首次上报TSDK_E_CONF_EVT_CONF_RESUMING_IND事件60秒内,未正常恢复会议,SDK会自动放弃恢复。