123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 |
- //
- // webSocketManager.m
- // 双子星云手机
- //
- // Created by xd h on 2024/6/20.
- //
- #import "webSocketManager.h"
- #import "webSocketManager+baseDownload.h"
- #import "webSocketManager+downloadFile.h"
- #import "webSocketManager+downloadThumbnailImage.h"
- #import "webSocketManager+upLoadFile.h"
- #import "webSocketManager+backupsFile.h"
- #import "errorAlertTool.h"
- #import "RcGameWQKeyChain.h"
- #import "USBInsertPopView.h"
- #import "nasMixUploadManager.h"
- @interface webSocketManager ()
- {
- NSMutableArray *commandSendCheckArr;//需要检测任务是否发出的的指令
- ComontAlretViewController *logoutAlertVC;
- USBInsertPopView *curUSBInsertPopV;
- }
- @property(copy,nonatomic)NSString *curIp;
- /**定时器计数*/
- @property (nonatomic, assign) NSInteger webSocketTime;
- /**定时器计数 任务检测*/
- @property (nonatomic, assign) NSInteger webSocketTaskTime;
- @property (nonatomic, copy) NSTimer *webSocketCheckTimer; // 定时器-控制按钮
- //第一次链接设备 要发送指令信息 实现单点登录
- @property (nonatomic, assign)BOOL didSendfristMsg;
- @end
- @implementation webSocketManager
- static webSocketManager *webSocketManagerInstance = nil;
- +(webSocketManager *)shareInstance;
- {
- static dispatch_once_t onceToken;
-
- dispatch_once(&onceToken, ^{
- webSocketManagerInstance = [[webSocketManager alloc] init];
- });
-
- return webSocketManagerInstance;
- }
- - (void)initOtherFun
- {
- if(_webSocketCheckTimer){
- //[_timer invalidate];
- return;
- }
-
- _webSocketCheckTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(webScoketTimerChange) userInfo:nil repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:_webSocketCheckTimer forMode:NSRunLoopCommonModes];
-
- commandSendCheckArr = [NSMutableArray new];
- }
- - (void)opencommandChannelManagerrc_openURL
- {
-
- }
- - (void)keepWebSocketOKFun
- {
- self.webSocketTime = 0;
- }
- - (void)WebSocketNeedRelinkFun
- {
- self.webSocketTime = 0;
-
- // if(self.commandChannelManager){
- // [self opencommandChannelManagerrc_openURL];
- // }
- }
- - (void)webScoketTimerChange {
-
- //处理websockt是否断开
- self.webSocketTime += 5;
-
- //处理其他任务
- self.webSocketTaskTime += 5;
-
- if(self.webSocketTime >= 10)
- {
- [self WebSocketNeedRelinkFun];
- }
-
- if(self.webSocketTaskTime >= 10)
- {
- self.webSocketTaskTime = 0;
- [self checkAllTaskFun];
-
- }
- }
- - (void)checkAllTaskFun
- {}
- //检测是否正在进行的文件传输任务
- - (void)checkFileTransfeTaskFun
- {
-
- //BOOL isBackupsingType = [[backupsFileManager shareInstance] checkBackupsingFun];
- BOOL isBackupsingType = [[nasBackupsManager shareInstance] checkBackupsingFun];
- //BOOL isUploadingType = [[uploadFileManager shareInstance] checkUploadingFun];
- BOOL isUploadingType = [[nasMixUploadManager shareManager] checkUploadTaskDoingFun];
- //BOOL isDownloadingType = [[downloadManager shareInstance] checkDownloadingFun];
- BOOL isDownloadingType = [[nasDownloadManager shareManager] isDownLoadIngType];
- BOOL isNasDownloadingType = [customDownloadManager shareManager].isDownLoadIngType;
-
- BOOL isBackground = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
-
- if ((isBackupsingType || isUploadingType || isDownloadingType ||isNasDownloadingType) && isBackground) {
- HLog(@"后台保活中");
- [cachesFileManager writeLogsWithMsg:@"Background working"];
- }
- else{
- HLog(@"停止后台保活");
- [cachesFileManager writeLogsWithMsg:@"stop Background working"];
- //[[AudioSessionObject shareManager] stopBackgroundActiveFun];
- }
-
- }
- -(void)checkCommandSendTaskFun
- {
- if(commandSendCheckArr && commandSendCheckArr.count >0){
- for (commandSendCheckModel *model in commandSendCheckArr) {
- if(model.reSendNum < 2){
- model.reSendNum ++;
- if(model.commandStr){
- [self send_data:model.commandStr];
-
- HLog(@"\n\n\n任务重发 重发次数:%ld 指令:%@\n\n\n",model.reSendNum,model.commandStr);
- }
-
- // if([model.type isEqualToString:@"offline_notification"]){
- // model.reSendNum = 1;//只要不收到
- // }
- }
- }
- }
- }
- - (void)send_data:(NSString *)dataStr
- {
- //[self.commandChannelManager rc_sendData:dataStr];
- }
- #pragma mark 盒子链接成功后需要处理的各种各样事情
- - (void)handlAllMsgAfterDidLinkFun
- {
- _isRebootIngType = NO;
- _isResetingType = NO;
- _isChangeBoxType = NO;
-
- ksharedAppDelegate.isWebSockLinkOKAginType = YES;
-
- //获取云机尺寸 兼容 720*1080 &1080*1920 不同分辨率的展示和触控
- NSString *getPhoneSizeStr = [RCCommandHelp getPhoneSizecommand];
- [self send_data:getPhoneSizeStr];
-
- //判断是否为需要改机
- BOOL isNeedRandomChangeParams = [HWDataManager getBoolWithKey:Const_need_random_Change_Params];
- if(isNeedRandomChangeParams)
- {
- NSString *commondStr = @"{\"type\":\"randomChangeParams\"}";
- [self send_data:commondStr];
-
- [HWDataManager setBoolWithKey:Const_need_random_Change_Params value:NO];
- }
-
- [self fristConnectNeedGiveAMsgFun];
-
- [self updateCopydata];
-
- // 报链接失败 后面又连接上了
- [[errorAlertTool shareInstance] dismissErrorAlertFun];
-
- //处理相册备份
- //[[backupsFileManager shareInstance] AutohandlePhotosBackupsFun];
- [[nasBackupsManager shareInstance] AutohandlePhotosBackupsFun];
-
- //获取磁盘外挂
- [self getExtraFilesListFun];
-
- [self getBaseInfoFun];
-
- [self getTvStatusFun];
- }
- #pragma mark 盒子第一次连接成功 给ws发送信息 单点登录 把其他账号挤下去
- - (void)fristConnectNeedGiveAMsgFun{
-
- if(!_didSendfristMsg )
- {
- [self getSysInfoFun];
-
- NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
- if(!curOaidStr){
- curOaidStr = @"";
- }
-
- //暂时屏蔽
- // NSString *commondStr = [[NSString alloc] initWithFormat:@"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\",\"sign\":\"%@\"}",curOaidStr];
- // //NSString *commondStr = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
- // [self send_data:commondStr];
- // [self addCommandSendTaskFunWithType:@"offline_notification" WithCommandStr:commondStr];
-
- _didSendfristMsg = YES;
-
- [self getPreferredLanguage];
-
- NSString *commondStr2 = @"{\"type\":\"TvStatus\"}";
- [self send_data:commondStr2];
- }
- }
- #pragma mark 语言和市区 同步云机
- -(void)getPreferredLanguage
- {//{"data":{"language":"zh-CN","timeZone":"Etc/GMT+8"},"type":"setLanguages"}
- // iOS 获取设备当前语言的代码
- NSString *preferredLanguage = [[[NSBundle mainBundle] preferredLocalizations] firstObject];
- HLog(@"当前语言:%@", preferredLanguage);
- //en-US 英文 ja-JP 日文
-
- NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
- NSLog(@"arLanguages:%@",arLanguages);
- ///获取设备当前地区的代码和APP语言环境
- NSString *languageCode = [NSLocale preferredLanguages][0];
-
-
- //目前支持 中文(简体 繁体) 英文 日语
- if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
- {
- preferredLanguage = @"zh-CN";
- }
- else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
- {
- preferredLanguage = @"zh-HK";
- }
- else if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
- {
- preferredLanguage = @"ja-JP";
- }
- else{
- preferredLanguage = @"en-US";
- }
-
- // if([languageCode rangeOfString:preferredLanguage].location != NSNotFound){
- // preferredLanguage = languageCode;
- // }
- // else{
- // preferredLanguage = @"en-US";
- // }
-
- NSString*gmtStr = [self UTCOffset];
- HLog(@"%@",gmtStr);
- // //获取名字,如“GMT+08:00
-
- NSString *commondStr = [NSString stringWithFormat:@"{\"type\":\"setLanguages\",\"data\":{\"language\":\"%@\",\"timeZone\":\"%@\"}}",preferredLanguage,gmtStr];
-
- [self send_data:commondStr];
-
- }
- -(NSString *)UTCOffset {
- NSTimeZone *localTZ = [NSTimeZone localTimeZone];
- float offset = localTZ.secondsFromGMT/3600.0;
- if(offset > 0){
- return [NSString stringWithFormat:@"Etc/GMT+%g",offset];
- }
- return [NSString stringWithFormat:@"Etc/GMT%g",offset];
- }
- #pragma mark 重启云机
- - (void)needToRebootFun
- {
- NSString *commondStr = @"{\"type\":\"reboot\"}";
- [self send_data:commondStr];
-
- //添加到任务监听
- [self addCommandSendTaskFunWithType:@"reboot" WithCommandStr:commondStr];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restart"];
-
- _isRebootIngType = YES;
- }
- - (void)needToResetFun
- {
- NSString *commondStr = @"{\"type\":\"reset\"}";
- [self send_data:commondStr];
-
- //添加到任务监听
- [self addCommandSendTaskFunWithType:@"reset" WithCommandStr:commondStr];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restore_factory"];
- _isResetingType = YES;
- }
- - (void)updateCopydata{
- UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
- NSString *str = [pasteboard string];
-
- HLog(@"__________%s______%@____",__func__,str);
-
- if ([str rangeOfString:@"CVLUSTERS_NOUSE_"].location != NSNotFound)
- {
- str = nil;
- }
-
- if (str && str.length >0)
- {
- //HLog(@"hxd111 cutting %@",str);
- /*发送数据*/
- NSString *dataStr = [RCCommandHelp commandCuttingWithContent:str];
- //[self.commandChannelManager rc_sendData:dataStr];
- //pasteboard.string = @"";
- }
-
- }
- #pragma mark 获取云机以及外挂磁盘
- - (void)getExtraFilesListFun
- {
- NSString *ExtraCommondStr = [RCCommandHelp getExtraFilesList];
- [self send_data:ExtraCommondStr];
- }
- -(void)addCommandSendTaskFunWithType:(NSString*)type WithCommandStr:(NSString*)commandStr
- {
- if(!commandSendCheckArr){
- commandSendCheckArr = [NSMutableArray new];
- }
-
- BOOL didAddType = NO;
-
- for (commandSendCheckModel *model in commandSendCheckArr) {
- if([model.type isEqualToString:type]){
- didAddType = YES;
- model.reSendNum = 0;
- model.sendTimerStamp = [iTools getNowTimeStamp];
- break;
- }
- }
-
- if(!didAddType){
- commandSendCheckModel *model = [commandSendCheckModel new];
- model.commandStr = commandStr;
- model.type = type;
- model.reSendNum = 0;
- model.sendTimerStamp = [iTools getNowTimeStamp];
- [commandSendCheckArr addObject:model];
- }
-
- }
- -(void)deleteCommandSendTaskFunWith:(NSString*)type
- {
- if(commandSendCheckArr && commandSendCheckArr.count >0){
-
- NSArray *taskArr = [NSArray arrayWithArray:commandSendCheckArr];
-
- for (commandSendCheckModel *model in taskArr) {
- if([type isEqualToString:model.type]){
- [commandSendCheckArr removeObject:model];
- }
- }
- }
- }
- #pragma mark wifi handle
- - (void)sync_wifiBackHandleFun
- {
- //[self.commandChannelManager rc_sendData:[RCCommandHelp noSyncWifiBack]];
- [[iToast makeText:NSLocalizedString(@"player_Tip_ios_no_wifi_Sync",nil)] show];
- }
- - (void)getCouldPhoneBaseInfoResponseFun:(NSDictionary *)dataDict
- {
- couldPhoneBaseInfoModel *model = [[couldPhoneBaseInfoModel alloc] initWithDictionary:dataDict error:nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneBaseInfoNotification object:model];
- }
- - (void)getCouldPhoneSysInfoResponseFun:(NSDictionary *)dataDict{
- couldphoneSysInfoModel *model = [[couldphoneSysInfoModel alloc] initWithDictionary:dataDict error:nil];
- //[[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
-
- // NSString *hostImgVer = model.data.data.hostImgVer;
- // NSString *MyNewVersion = model.data.data.MyNewVersion;
-
- NSString *hostImgVer = model.data.hostImgVer;
- NSString *MyNewVersion = model.data.MyNewVersion;
- //test code
- // hostImgVer = @"1.2.3";
- // MyNewVersion = @"1.2.0";
-
- //判断当前版本号 待更新版本
- if (!hostImgVer || hostImgVer.length < 3
- ||!MyNewVersion || MyNewVersion.length < 3) {
- return;
- }
-
- NSArray *versionArr = [hostImgVer componentsSeparatedByString:@"."];
- NSArray *MyNewVersionArr = [MyNewVersion componentsSeparatedByString:@"."];
-
- NSInteger versionArrCount = versionArr.count;
- NSInteger MyNewVersionArrCount = MyNewVersionArr.count;
- NSInteger maxCount = versionArrCount < MyNewVersionArrCount ? versionArrCount:MyNewVersionArrCount;
-
- BOOL isNeedShowType = NO;
- //判断是否要更新镜像框
- if(maxCount > 0){
- for (int i=0; i<maxCount; i++) {
- NSString * numberStr1 = versionArr[i];
- NSString * numberStr2 = MyNewVersionArr[i];
-
- if(numberStr2.intValue > numberStr1.intValue){
- isNeedShowType =YES;
- break;
- }
- }
- }
-
-
- if(isNeedShowType){
- ksharedAppDelegate.isNeedShowImageNewType = YES;
- }
-
- //是否禁用文件传输 (1.3以及以上的镜像可以使用文件传输)
- if(versionArr.count >= 3)
- {
- NSString * oneStr = versionArr[0];
- NSString * twoStr = versionArr[1];
- NSString * threeStr = versionArr[2];
- if(oneStr.integerValue <=1 && twoStr.integerValue <=3 && threeStr.integerValue <=0){//禁用
- ksharedAppDelegate.DisabledFileTransferType = YES;
-
- if(MyNewVersionArr.count >= 3)
- {
- NSString * newOneStr = MyNewVersionArr[0];
- NSString * newTwoStr = MyNewVersionArr[1];
- NSString * newThreeStr = MyNewVersionArr[2];
-
- if(newOneStr.integerValue >=1 && newTwoStr.integerValue >=3 && newThreeStr.integerValue >= 1){
- ksharedAppDelegate.isImageNewFor130 = YES;
- }
- else{
- ksharedAppDelegate.isImageNewFor130 = NO;
- }
- }
- }
- else{
- ksharedAppDelegate.DisabledFileTransferType = NO;
- }
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
- }
- - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict
- {
- TvStatusModel *model = [[TvStatusModel alloc] initWithDictionary:dataDict error:nil];
- ksharedAppDelegate.TvStatusMod = model;
-
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
-
- // if(![model.msg containsString:@"PushStreamBActivity"])
- // {
- // return;
- // }
- //
- // UIViewController*topVc = self.navigationController.viewControllers.lastObject;
- // if([topVc isKindOfClass:[PlayerViewController class]]){
- // [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
- // }
- }
- - (void)createFolderResponseFun:(NSDictionary *)dataDict
- {
- couldPhoneCommonModel *model = [[couldPhoneCommonModel alloc] initWithDictionary:dataDict error:nil];
-
- if(model){
- NSNumber *curNum = [NSNumber numberWithInteger:model.status];
- [[NSNotificationCenter defaultCenter] postNotificationName:createFolderDoneNotification object:curNum];/*发送通知*/
- }
- }
- - (void)getFolderListResponseFun:(NSDictionary *)dataDict
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:getFolderListDoneNotification object:dataDict];/*发送通知*/
- }
- - (void)searchFileListResponseFun:(NSDictionary *)dataDict
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListDoneNotification object:dataDict];/*发送通知*/
- }
- #pragma mark 获取云机已经外挂产品
- - (void)getExtraFilesResponseFun:(NSDictionary *)dataDict
- {
- cloudPhoneExtraFileListModel *model = [[cloudPhoneExtraFileListModel alloc] initWithDictionary:dataDict error:nil];
- ksharedAppDelegate.cloudPhoneExtraFileListMod = model;
-
- [[NSNotificationCenter defaultCenter] postNotificationName:getExtraFilesDoneNotification object:dataDict];/*发送通知*/
- }
- - (void)getExtraMediaEventResponseFun:(NSDictionary *)dataDict
- {
- extraMediaEventModel *model = [[extraMediaEventModel alloc] initWithDictionary:dataDict error:nil];
-
- NSString *tip = nil;
- if(model.data.event == 0){
- tip = NSLocalizedString(@"disk_insertion_tip",nil);
- [self showInsertPopViewFun:model.data.name];
- }
- else if(model.data.event == 1){
- tip = NSLocalizedString(@"disk_extract_tip",nil);
- }
- else if(model.data.event == 2){
- tip = NSLocalizedString(@"disk_save_extract_tip",nil);
- }
-
- NSString *totalTips = [[NSString alloc] initWithFormat:@"%@%@",model.data.name,tip];
-
- mainBlock(^{
- [[iToast makeText:totalTips] show];
- });
- }
- #pragma mark 显示插入UI弹框
- - (void)showInsertPopViewFun:(NSString*)name
- {
- // if(self->curUSBInsertPopV){
- // [self->curUSBInsertPopV removeFromSuperview];
- // self->curUSBInsertPopV = nil;
- // }
- //
- // self->curUSBInsertPopV = [[USBInsertPopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H) withName:name];
- //
- // [[iTools getKeyWindow] addSubview:self->curUSBInsertPopV];
- }
- - (void)createBackupsFolderBy:(NSString*)backupsDefaultPath
- {
- NSString *folderName = backupsDefaultPath;
-
- if(folderName && folderName.length >0){
- NSString * commandStr = [RCCommandHelp applyForCreateFolderwithFolderName:folderName];
- //[self.commandChannelManager rc_sendData:commandStr];
- }
- }
- - (void)getBackupFolderListFun
- {
- NSString * commandStr = [RCCommandHelp getCreateFolderList];
- //[self.commandChannelManager rc_sendData:commandStr];
- }
- - (void)searchFileListBeginFun:(NSMutableDictionary *)dict
- {
- NSMutableDictionary *objectDict = dict;
- NSNumber *curNum = @1;
-
- if ([[objectDict allKeys] containsObject:@"type"]) {
- curNum = [objectDict objectForKey:@"type"];
- }
-
- NSString *pathStr = @"";
-
- if ([[objectDict allKeys] containsObject:@"path"]) {
- pathStr = [objectDict objectForKey:@"path"];
- }
-
- NSString *fileType = @"video";
-
- if(curNum.boolValue)
- {
- fileType = @"jpg";
- }
-
- NSString * commandStr = [RCCommandHelp searchCouldPhoneFilewithType:fileType withPath:pathStr];
- //[self.commandChannelManager rc_sendData:commandStr];
- }
- #pragma mark 获取云机基本信息
- - (void)getBaseInfoFun
- {
- NSString *commondStr = @"{\"type\":\"getBaseInfo\"}";
- [self send_data:commondStr];
- }
- #pragma mark 获取云机系统镜像等信息
- - (void)getSysInfoFun
- {
- NSString *commondStr = @"{\"type\":\"getSysInfo\"}";
- [self send_data:commondStr];
- }
- #pragma mark 云机截图保存到云机图库
- - (void)screenshotInCloudPhoneFun{
- NSString*taskUid = [iTools getTaskUidStr];
- NSString *commondStr = [RCCommandHelp commandCloudPhoneScreenshotWithTaskUid:taskUid];
- [self send_data:commondStr];
- }
- #pragma mark 获取TV投屏状态
- - (void)getTvStatusFun
- {
- NSString *commondStr = @"{\"type\":\"TvStatus\"}";
- [self send_data:commondStr];
- }
- #pragma mark 关闭TV投屏状态
- - (void)offTvFun
- {
- NSString *commondStr = @"{\"type\":\"TvOff\"}";
- [self send_data:commondStr];
- }
- #pragma mark 开启TV投屏状态
- - (void)onTvFun
- {
- NSString *commondStr = @"{\"type\":\"wakeupTV\"}";
- [self send_data:commondStr];
- }
- #pragma mark 告诉别的ws收到的挤下线消息
- - (void)didReceiveLogoutMsgFun
- {
- NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
- if(!curOaidStr){
- curOaidStr = @"";
- }
- NSString *commondStr = [[NSString alloc] initWithFormat:@"{\"type\":\"forwardMsg\",\"data\":\"only one socket2\",\"sign\":\"%@\"}",curOaidStr];
- //NSString *commondStr = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
- [self send_data:commondStr];
- }
- #pragma mark 单点登录被挤下线弹框
- - (void)LogoutByOtherFun
- {
-
- if(logoutAlertVC){
- return;
- }
-
- [self didReceiveLogoutMsgFun];
-
- //通知音视频断开链接
- [[NSNotificationCenter defaultCenter] postNotificationName:logoutByOtherNotification object:nil];
-
- //yyyy-MM-dd HH:mm:ss
- NSString*dateStr = [iTools getNowTimeString2];
- if(dateStr && dateStr.length == 19){
- dateStr = [dateStr substringWithRange:NSMakeRange(11, 5)];
- }
-
- NSString *LogoutTimerStr = [[NSString alloc] initWithFormat:@"%@%@%@",NSLocalizedString(@"single_sign_on_Tips_one",nil),dateStr,NSLocalizedString(@"single_sign_on_Tips_two",nil)];
-
-
- NSString * loginAgainStr = NSLocalizedString(@"single_sign_on_login_again",nil);
- BOOL isOkBtnHighlight = YES;
- if(!ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
- loginAgainStr = @"";
- isOkBtnHighlight = NO;
- }
-
- _isLogoutByOtherType = YES;
- _didSendfristMsg = NO;
- _isWaitShowLogoutAlert = YES;
-
- //被挤下线 ws断开
- //[self.commandChannelManager rc_close];
- //self.commandChannelManager = nil;
-
- if([DFPlayer sharedPlayer].currentAudioModel
- &&([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
- || [DFPlayer sharedPlayer].state == DFPlayerStatePlaying)
- ){
- [[DFPlayer sharedPlayer] df_pause];
- [[audioPlayingView sharedInstance] setAudioPlayingStateFunBy:NO];
- }
-
-
- if(ksharedAppDelegate.isDidShowPwdType){
-
- KWeakSelf
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf LogoutByOtherFun];
- HLog(@"weakSelf LogoutByOtherFun")
- });
- return;
- }
-
- _isWaitShowLogoutAlert = NO;;
-
- /*弹窗提示重启*/
- //KWeakSelf
- logoutAlertVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"single_sign_on_Tips_logout",nil)
- msg:LogoutTimerStr
- imageStr:@""
- cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
- okTitle:loginAgainStr isOkBtnHighlight:isOkBtnHighlight
- didClickOk:^{
- //[weakSelf tryAgain];
- //[[webSocketManager shareInstance] WebSocketNeedRelinkFun];
-
- self->_isLogoutByOtherType = NO;
- self->logoutAlertVC = nil;
- [[NSNotificationCenter defaultCenter] postNotificationName:lockBypwdNotification object:nil];
-
- } didClickCancel:^{
- exit(0);/*强制退出app*/
- }];
- logoutAlertVC.modalPresentationStyle = UIModalPresentationCustom;
- [[iTools appRootViewController] presentViewController:logoutAlertVC animated:YES completion:^{
- self->logoutAlertVC.view.superview.backgroundColor = [UIColor clearColor];
- }];
-
- }
- @end
|