webSocketManager.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. //
  2. // webSocketManager.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/20.
  6. //
  7. #import "webSocketManager.h"
  8. #import "webSocketManager+baseDownload.h"
  9. #import "webSocketManager+downloadFile.h"
  10. #import "webSocketManager+downloadThumbnailImage.h"
  11. #import "webSocketManager+upLoadFile.h"
  12. #import "webSocketManager+backupsFile.h"
  13. #import "errorAlertTool.h"
  14. #import "RcGameWQKeyChain.h"
  15. #import "USBInsertPopView.h"
  16. #import "nasMixUploadManager.h"
  17. @interface webSocketManager ()
  18. {
  19. NSMutableArray *commandSendCheckArr;//需要检测任务是否发出的的指令
  20. ComontAlretViewController *logoutAlertVC;
  21. USBInsertPopView *curUSBInsertPopV;
  22. }
  23. @property(copy,nonatomic)NSString *curIp;
  24. /**定时器计数*/
  25. @property (nonatomic, assign) NSInteger webSocketTime;
  26. /**定时器计数 任务检测*/
  27. @property (nonatomic, assign) NSInteger webSocketTaskTime;
  28. @property (nonatomic, copy) NSTimer *webSocketCheckTimer; // 定时器-控制按钮
  29. //第一次链接设备 要发送指令信息 实现单点登录
  30. @property (nonatomic, assign)BOOL didSendfristMsg;
  31. @end
  32. @implementation webSocketManager
  33. static webSocketManager *webSocketManagerInstance = nil;
  34. +(webSocketManager *)shareInstance;
  35. {
  36. static dispatch_once_t onceToken;
  37. dispatch_once(&onceToken, ^{
  38. webSocketManagerInstance = [[webSocketManager alloc] init];
  39. });
  40. return webSocketManagerInstance;
  41. }
  42. - (void)initOtherFun
  43. {
  44. if(_webSocketCheckTimer){
  45. //[_timer invalidate];
  46. return;
  47. }
  48. _webSocketCheckTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(webScoketTimerChange) userInfo:nil repeats:YES];
  49. [[NSRunLoop currentRunLoop] addTimer:_webSocketCheckTimer forMode:NSRunLoopCommonModes];
  50. commandSendCheckArr = [NSMutableArray new];
  51. }
  52. - (void)opencommandChannelManagerrc_openURL
  53. {
  54. }
  55. - (void)keepWebSocketOKFun
  56. {
  57. self.webSocketTime = 0;
  58. }
  59. - (void)WebSocketNeedRelinkFun
  60. {
  61. self.webSocketTime = 0;
  62. // if(self.commandChannelManager){
  63. // [self opencommandChannelManagerrc_openURL];
  64. // }
  65. }
  66. - (void)webScoketTimerChange {
  67. //处理websockt是否断开
  68. self.webSocketTime += 5;
  69. //处理其他任务
  70. self.webSocketTaskTime += 5;
  71. if(self.webSocketTime >= 10)
  72. {
  73. [self WebSocketNeedRelinkFun];
  74. }
  75. if(self.webSocketTaskTime >= 10)
  76. {
  77. self.webSocketTaskTime = 0;
  78. [self checkAllTaskFun];
  79. }
  80. }
  81. - (void)checkAllTaskFun
  82. {}
  83. //检测是否正在进行的文件传输任务
  84. - (void)checkFileTransfeTaskFun
  85. {
  86. //BOOL isBackupsingType = [[backupsFileManager shareInstance] checkBackupsingFun];
  87. BOOL isBackupsingType = [[nasBackupsManager shareInstance] checkBackupsingFun];
  88. //BOOL isUploadingType = [[uploadFileManager shareInstance] checkUploadingFun];
  89. BOOL isUploadingType = [[nasMixUploadManager shareManager] checkUploadTaskDoingFun];
  90. //BOOL isDownloadingType = [[downloadManager shareInstance] checkDownloadingFun];
  91. BOOL isDownloadingType = [[nasDownloadManager shareManager] isDownLoadIngType];
  92. BOOL isNasDownloadingType = [customDownloadManager shareManager].isDownLoadIngType;
  93. BOOL isBackground = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_working_background)];
  94. if ((isBackupsingType || isUploadingType || isDownloadingType ||isNasDownloadingType) && isBackground) {
  95. HLog(@"后台保活中");
  96. [cachesFileManager writeLogsWithMsg:@"Background working"];
  97. }
  98. else{
  99. HLog(@"停止后台保活");
  100. [cachesFileManager writeLogsWithMsg:@"stop Background working"];
  101. //[[AudioSessionObject shareManager] stopBackgroundActiveFun];
  102. }
  103. }
  104. -(void)checkCommandSendTaskFun
  105. {
  106. if(commandSendCheckArr && commandSendCheckArr.count >0){
  107. for (commandSendCheckModel *model in commandSendCheckArr) {
  108. if(model.reSendNum < 2){
  109. model.reSendNum ++;
  110. if(model.commandStr){
  111. [self send_data:model.commandStr];
  112. HLog(@"\n\n\n任务重发 重发次数:%ld 指令:%@\n\n\n",model.reSendNum,model.commandStr);
  113. }
  114. // if([model.type isEqualToString:@"offline_notification"]){
  115. // model.reSendNum = 1;//只要不收到
  116. // }
  117. }
  118. }
  119. }
  120. }
  121. - (void)send_data:(NSString *)dataStr
  122. {
  123. //[self.commandChannelManager rc_sendData:dataStr];
  124. }
  125. #pragma mark 盒子链接成功后需要处理的各种各样事情
  126. - (void)handlAllMsgAfterDidLinkFun
  127. {
  128. _isRebootIngType = NO;
  129. _isResetingType = NO;
  130. _isChangeBoxType = NO;
  131. ksharedAppDelegate.isWebSockLinkOKAginType = YES;
  132. //获取云机尺寸 兼容 720*1080 &1080*1920 不同分辨率的展示和触控
  133. NSString *getPhoneSizeStr = [RCCommandHelp getPhoneSizecommand];
  134. [self send_data:getPhoneSizeStr];
  135. //判断是否为需要改机
  136. BOOL isNeedRandomChangeParams = [HWDataManager getBoolWithKey:Const_need_random_Change_Params];
  137. if(isNeedRandomChangeParams)
  138. {
  139. NSString *commondStr = @"{\"type\":\"randomChangeParams\"}";
  140. [self send_data:commondStr];
  141. [HWDataManager setBoolWithKey:Const_need_random_Change_Params value:NO];
  142. }
  143. [self fristConnectNeedGiveAMsgFun];
  144. [self updateCopydata];
  145. // 报链接失败 后面又连接上了
  146. [[errorAlertTool shareInstance] dismissErrorAlertFun];
  147. //处理相册备份
  148. //[[backupsFileManager shareInstance] AutohandlePhotosBackupsFun];
  149. [[nasBackupsManager shareInstance] AutohandlePhotosBackupsFun];
  150. //获取磁盘外挂
  151. [self getExtraFilesListFun];
  152. [self getBaseInfoFun];
  153. [self getTvStatusFun];
  154. }
  155. #pragma mark 盒子第一次连接成功 给ws发送信息 单点登录 把其他账号挤下去
  156. - (void)fristConnectNeedGiveAMsgFun{
  157. if(!_didSendfristMsg )
  158. {
  159. [self getSysInfoFun];
  160. NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
  161. if(!curOaidStr){
  162. curOaidStr = @"";
  163. }
  164. //暂时屏蔽
  165. // NSString *commondStr = [[NSString alloc] initWithFormat:@"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\",\"sign\":\"%@\"}",curOaidStr];
  166. // //NSString *commondStr = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
  167. // [self send_data:commondStr];
  168. // [self addCommandSendTaskFunWithType:@"offline_notification" WithCommandStr:commondStr];
  169. _didSendfristMsg = YES;
  170. [self getPreferredLanguage];
  171. NSString *commondStr2 = @"{\"type\":\"TvStatus\"}";
  172. [self send_data:commondStr2];
  173. }
  174. }
  175. #pragma mark 语言和市区 同步云机
  176. -(void)getPreferredLanguage
  177. {//{"data":{"language":"zh-CN","timeZone":"Etc/GMT+8"},"type":"setLanguages"}
  178. // iOS 获取设备当前语言的代码
  179. NSString *preferredLanguage = [[[NSBundle mainBundle] preferredLocalizations] firstObject];
  180. HLog(@"当前语言:%@", preferredLanguage);
  181. //en-US 英文 ja-JP 日文
  182. NSArray *arLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
  183. NSLog(@"arLanguages:%@",arLanguages);
  184. ///获取设备当前地区的代码和APP语言环境
  185. NSString *languageCode = [NSLocale preferredLanguages][0];
  186. //目前支持 中文(简体 繁体) 英文 日语
  187. if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
  188. {
  189. preferredLanguage = @"zh-CN";
  190. }
  191. else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
  192. {
  193. preferredLanguage = @"zh-HK";
  194. }
  195. else if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
  196. {
  197. preferredLanguage = @"ja-JP";
  198. }
  199. else{
  200. preferredLanguage = @"en-US";
  201. }
  202. // if([languageCode rangeOfString:preferredLanguage].location != NSNotFound){
  203. // preferredLanguage = languageCode;
  204. // }
  205. // else{
  206. // preferredLanguage = @"en-US";
  207. // }
  208. NSString*gmtStr = [self UTCOffset];
  209. HLog(@"%@",gmtStr);
  210. // //获取名字,如“GMT+08:00
  211. NSString *commondStr = [NSString stringWithFormat:@"{\"type\":\"setLanguages\",\"data\":{\"language\":\"%@\",\"timeZone\":\"%@\"}}",preferredLanguage,gmtStr];
  212. [self send_data:commondStr];
  213. }
  214. -(NSString *)UTCOffset {
  215. NSTimeZone *localTZ = [NSTimeZone localTimeZone];
  216. float offset = localTZ.secondsFromGMT/3600.0;
  217. if(offset > 0){
  218. return [NSString stringWithFormat:@"Etc/GMT+%g",offset];
  219. }
  220. return [NSString stringWithFormat:@"Etc/GMT%g",offset];
  221. }
  222. #pragma mark 重启云机
  223. - (void)needToRebootFun
  224. {
  225. NSString *commondStr = @"{\"type\":\"reboot\"}";
  226. [self send_data:commondStr];
  227. //添加到任务监听
  228. [self addCommandSendTaskFunWithType:@"reboot" WithCommandStr:commondStr];
  229. //数据埋点
  230. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restart"];
  231. _isRebootIngType = YES;
  232. }
  233. - (void)needToResetFun
  234. {
  235. NSString *commondStr = @"{\"type\":\"reset\"}";
  236. [self send_data:commondStr];
  237. //添加到任务监听
  238. [self addCommandSendTaskFunWithType:@"reset" WithCommandStr:commondStr];
  239. //数据埋点
  240. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_restore_factory"];
  241. _isResetingType = YES;
  242. }
  243. - (void)updateCopydata{
  244. UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
  245. NSString *str = [pasteboard string];
  246. HLog(@"__________%s______%@____",__func__,str);
  247. if ([str rangeOfString:@"CVLUSTERS_NOUSE_"].location != NSNotFound)
  248. {
  249. str = nil;
  250. }
  251. if (str && str.length >0)
  252. {
  253. //HLog(@"hxd111 cutting %@",str);
  254. /*发送数据*/
  255. NSString *dataStr = [RCCommandHelp commandCuttingWithContent:str];
  256. //[self.commandChannelManager rc_sendData:dataStr];
  257. //pasteboard.string = @"";
  258. }
  259. }
  260. #pragma mark 获取云机以及外挂磁盘
  261. - (void)getExtraFilesListFun
  262. {
  263. NSString *ExtraCommondStr = [RCCommandHelp getExtraFilesList];
  264. [self send_data:ExtraCommondStr];
  265. }
  266. -(void)addCommandSendTaskFunWithType:(NSString*)type WithCommandStr:(NSString*)commandStr
  267. {
  268. if(!commandSendCheckArr){
  269. commandSendCheckArr = [NSMutableArray new];
  270. }
  271. BOOL didAddType = NO;
  272. for (commandSendCheckModel *model in commandSendCheckArr) {
  273. if([model.type isEqualToString:type]){
  274. didAddType = YES;
  275. model.reSendNum = 0;
  276. model.sendTimerStamp = [iTools getNowTimeStamp];
  277. break;
  278. }
  279. }
  280. if(!didAddType){
  281. commandSendCheckModel *model = [commandSendCheckModel new];
  282. model.commandStr = commandStr;
  283. model.type = type;
  284. model.reSendNum = 0;
  285. model.sendTimerStamp = [iTools getNowTimeStamp];
  286. [commandSendCheckArr addObject:model];
  287. }
  288. }
  289. -(void)deleteCommandSendTaskFunWith:(NSString*)type
  290. {
  291. if(commandSendCheckArr && commandSendCheckArr.count >0){
  292. NSArray *taskArr = [NSArray arrayWithArray:commandSendCheckArr];
  293. for (commandSendCheckModel *model in taskArr) {
  294. if([type isEqualToString:model.type]){
  295. [commandSendCheckArr removeObject:model];
  296. }
  297. }
  298. }
  299. }
  300. #pragma mark wifi handle
  301. - (void)sync_wifiBackHandleFun
  302. {
  303. //[self.commandChannelManager rc_sendData:[RCCommandHelp noSyncWifiBack]];
  304. [[iToast makeText:NSLocalizedString(@"player_Tip_ios_no_wifi_Sync",nil)] show];
  305. }
  306. - (void)getCouldPhoneBaseInfoResponseFun:(NSDictionary *)dataDict
  307. {
  308. couldPhoneBaseInfoModel *model = [[couldPhoneBaseInfoModel alloc] initWithDictionary:dataDict error:nil];
  309. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneBaseInfoNotification object:model];
  310. }
  311. - (void)getCouldPhoneSysInfoResponseFun:(NSDictionary *)dataDict{
  312. couldphoneSysInfoModel *model = [[couldphoneSysInfoModel alloc] initWithDictionary:dataDict error:nil];
  313. //[[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
  314. // NSString *hostImgVer = model.data.data.hostImgVer;
  315. // NSString *MyNewVersion = model.data.data.MyNewVersion;
  316. NSString *hostImgVer = model.data.hostImgVer;
  317. NSString *MyNewVersion = model.data.MyNewVersion;
  318. //test code
  319. // hostImgVer = @"1.2.3";
  320. // MyNewVersion = @"1.2.0";
  321. //判断当前版本号 待更新版本
  322. if (!hostImgVer || hostImgVer.length < 3
  323. ||!MyNewVersion || MyNewVersion.length < 3) {
  324. return;
  325. }
  326. NSArray *versionArr = [hostImgVer componentsSeparatedByString:@"."];
  327. NSArray *MyNewVersionArr = [MyNewVersion componentsSeparatedByString:@"."];
  328. NSInteger versionArrCount = versionArr.count;
  329. NSInteger MyNewVersionArrCount = MyNewVersionArr.count;
  330. NSInteger maxCount = versionArrCount < MyNewVersionArrCount ? versionArrCount:MyNewVersionArrCount;
  331. BOOL isNeedShowType = NO;
  332. //判断是否要更新镜像框
  333. if(maxCount > 0){
  334. for (int i=0; i<maxCount; i++) {
  335. NSString * numberStr1 = versionArr[i];
  336. NSString * numberStr2 = MyNewVersionArr[i];
  337. if(numberStr2.intValue > numberStr1.intValue){
  338. isNeedShowType =YES;
  339. break;
  340. }
  341. }
  342. }
  343. if(isNeedShowType){
  344. ksharedAppDelegate.isNeedShowImageNewType = YES;
  345. }
  346. //是否禁用文件传输 (1.3以及以上的镜像可以使用文件传输)
  347. if(versionArr.count >= 3)
  348. {
  349. NSString * oneStr = versionArr[0];
  350. NSString * twoStr = versionArr[1];
  351. NSString * threeStr = versionArr[2];
  352. if(oneStr.integerValue <=1 && twoStr.integerValue <=3 && threeStr.integerValue <=0){//禁用
  353. ksharedAppDelegate.DisabledFileTransferType = YES;
  354. if(MyNewVersionArr.count >= 3)
  355. {
  356. NSString * newOneStr = MyNewVersionArr[0];
  357. NSString * newTwoStr = MyNewVersionArr[1];
  358. NSString * newThreeStr = MyNewVersionArr[2];
  359. if(newOneStr.integerValue >=1 && newTwoStr.integerValue >=3 && newThreeStr.integerValue >= 1){
  360. ksharedAppDelegate.isImageNewFor130 = YES;
  361. }
  362. else{
  363. ksharedAppDelegate.isImageNewFor130 = NO;
  364. }
  365. }
  366. }
  367. else{
  368. ksharedAppDelegate.DisabledFileTransferType = NO;
  369. }
  370. }
  371. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
  372. }
  373. - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict
  374. {
  375. TvStatusModel *model = [[TvStatusModel alloc] initWithDictionary:dataDict error:nil];
  376. ksharedAppDelegate.TvStatusMod = model;
  377. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
  378. // if(![model.msg containsString:@"PushStreamBActivity"])
  379. // {
  380. // return;
  381. // }
  382. //
  383. // UIViewController*topVc = self.navigationController.viewControllers.lastObject;
  384. // if([topVc isKindOfClass:[PlayerViewController class]]){
  385. // [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
  386. // }
  387. }
  388. - (void)createFolderResponseFun:(NSDictionary *)dataDict
  389. {
  390. couldPhoneCommonModel *model = [[couldPhoneCommonModel alloc] initWithDictionary:dataDict error:nil];
  391. if(model){
  392. NSNumber *curNum = [NSNumber numberWithInteger:model.status];
  393. [[NSNotificationCenter defaultCenter] postNotificationName:createFolderDoneNotification object:curNum];/*发送通知*/
  394. }
  395. }
  396. - (void)getFolderListResponseFun:(NSDictionary *)dataDict
  397. {
  398. [[NSNotificationCenter defaultCenter] postNotificationName:getFolderListDoneNotification object:dataDict];/*发送通知*/
  399. }
  400. - (void)searchFileListResponseFun:(NSDictionary *)dataDict
  401. {
  402. [[NSNotificationCenter defaultCenter] postNotificationName:searchFileListDoneNotification object:dataDict];/*发送通知*/
  403. }
  404. #pragma mark 获取云机已经外挂产品
  405. - (void)getExtraFilesResponseFun:(NSDictionary *)dataDict
  406. {
  407. cloudPhoneExtraFileListModel *model = [[cloudPhoneExtraFileListModel alloc] initWithDictionary:dataDict error:nil];
  408. ksharedAppDelegate.cloudPhoneExtraFileListMod = model;
  409. [[NSNotificationCenter defaultCenter] postNotificationName:getExtraFilesDoneNotification object:dataDict];/*发送通知*/
  410. }
  411. - (void)getExtraMediaEventResponseFun:(NSDictionary *)dataDict
  412. {
  413. extraMediaEventModel *model = [[extraMediaEventModel alloc] initWithDictionary:dataDict error:nil];
  414. NSString *tip = nil;
  415. if(model.data.event == 0){
  416. tip = NSLocalizedString(@"disk_insertion_tip",nil);
  417. [self showInsertPopViewFun:model.data.name];
  418. }
  419. else if(model.data.event == 1){
  420. tip = NSLocalizedString(@"disk_extract_tip",nil);
  421. }
  422. else if(model.data.event == 2){
  423. tip = NSLocalizedString(@"disk_save_extract_tip",nil);
  424. }
  425. NSString *totalTips = [[NSString alloc] initWithFormat:@"%@%@",model.data.name,tip];
  426. mainBlock(^{
  427. [[iToast makeText:totalTips] show];
  428. });
  429. }
  430. #pragma mark 显示插入UI弹框
  431. - (void)showInsertPopViewFun:(NSString*)name
  432. {
  433. // if(self->curUSBInsertPopV){
  434. // [self->curUSBInsertPopV removeFromSuperview];
  435. // self->curUSBInsertPopV = nil;
  436. // }
  437. //
  438. // self->curUSBInsertPopV = [[USBInsertPopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H) withName:name];
  439. //
  440. // [[iTools getKeyWindow] addSubview:self->curUSBInsertPopV];
  441. }
  442. - (void)createBackupsFolderBy:(NSString*)backupsDefaultPath
  443. {
  444. NSString *folderName = backupsDefaultPath;
  445. if(folderName && folderName.length >0){
  446. NSString * commandStr = [RCCommandHelp applyForCreateFolderwithFolderName:folderName];
  447. //[self.commandChannelManager rc_sendData:commandStr];
  448. }
  449. }
  450. - (void)getBackupFolderListFun
  451. {
  452. NSString * commandStr = [RCCommandHelp getCreateFolderList];
  453. //[self.commandChannelManager rc_sendData:commandStr];
  454. }
  455. - (void)searchFileListBeginFun:(NSMutableDictionary *)dict
  456. {
  457. NSMutableDictionary *objectDict = dict;
  458. NSNumber *curNum = @1;
  459. if ([[objectDict allKeys] containsObject:@"type"]) {
  460. curNum = [objectDict objectForKey:@"type"];
  461. }
  462. NSString *pathStr = @"";
  463. if ([[objectDict allKeys] containsObject:@"path"]) {
  464. pathStr = [objectDict objectForKey:@"path"];
  465. }
  466. NSString *fileType = @"video";
  467. if(curNum.boolValue)
  468. {
  469. fileType = @"jpg";
  470. }
  471. NSString * commandStr = [RCCommandHelp searchCouldPhoneFilewithType:fileType withPath:pathStr];
  472. //[self.commandChannelManager rc_sendData:commandStr];
  473. }
  474. #pragma mark 获取云机基本信息
  475. - (void)getBaseInfoFun
  476. {
  477. NSString *commondStr = @"{\"type\":\"getBaseInfo\"}";
  478. [self send_data:commondStr];
  479. }
  480. #pragma mark 获取云机系统镜像等信息
  481. - (void)getSysInfoFun
  482. {
  483. NSString *commondStr = @"{\"type\":\"getSysInfo\"}";
  484. [self send_data:commondStr];
  485. }
  486. #pragma mark 云机截图保存到云机图库
  487. - (void)screenshotInCloudPhoneFun{
  488. NSString*taskUid = [iTools getTaskUidStr];
  489. NSString *commondStr = [RCCommandHelp commandCloudPhoneScreenshotWithTaskUid:taskUid];
  490. [self send_data:commondStr];
  491. }
  492. #pragma mark 获取TV投屏状态
  493. - (void)getTvStatusFun
  494. {
  495. NSString *commondStr = @"{\"type\":\"TvStatus\"}";
  496. [self send_data:commondStr];
  497. }
  498. #pragma mark 关闭TV投屏状态
  499. - (void)offTvFun
  500. {
  501. NSString *commondStr = @"{\"type\":\"TvOff\"}";
  502. [self send_data:commondStr];
  503. }
  504. #pragma mark 开启TV投屏状态
  505. - (void)onTvFun
  506. {
  507. NSString *commondStr = @"{\"type\":\"wakeupTV\"}";
  508. [self send_data:commondStr];
  509. }
  510. #pragma mark 告诉别的ws收到的挤下线消息
  511. - (void)didReceiveLogoutMsgFun
  512. {
  513. NSString *curOaidStr = [RcGameWQKeyChain getOaidStringFun];
  514. if(!curOaidStr){
  515. curOaidStr = @"";
  516. }
  517. NSString *commondStr = [[NSString alloc] initWithFormat:@"{\"type\":\"forwardMsg\",\"data\":\"only one socket2\",\"sign\":\"%@\"}",curOaidStr];
  518. //NSString *commondStr = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
  519. [self send_data:commondStr];
  520. }
  521. #pragma mark 单点登录被挤下线弹框
  522. - (void)LogoutByOtherFun
  523. {
  524. if(logoutAlertVC){
  525. return;
  526. }
  527. [self didReceiveLogoutMsgFun];
  528. //通知音视频断开链接
  529. [[NSNotificationCenter defaultCenter] postNotificationName:logoutByOtherNotification object:nil];
  530. //yyyy-MM-dd HH:mm:ss
  531. NSString*dateStr = [iTools getNowTimeString2];
  532. if(dateStr && dateStr.length == 19){
  533. dateStr = [dateStr substringWithRange:NSMakeRange(11, 5)];
  534. }
  535. NSString *LogoutTimerStr = [[NSString alloc] initWithFormat:@"%@%@%@",NSLocalizedString(@"single_sign_on_Tips_one",nil),dateStr,NSLocalizedString(@"single_sign_on_Tips_two",nil)];
  536. NSString * loginAgainStr = NSLocalizedString(@"single_sign_on_login_again",nil);
  537. BOOL isOkBtnHighlight = YES;
  538. if(!ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
  539. loginAgainStr = @"";
  540. isOkBtnHighlight = NO;
  541. }
  542. _isLogoutByOtherType = YES;
  543. _didSendfristMsg = NO;
  544. _isWaitShowLogoutAlert = YES;
  545. //被挤下线 ws断开
  546. //[self.commandChannelManager rc_close];
  547. //self.commandChannelManager = nil;
  548. if([DFPlayer sharedPlayer].currentAudioModel
  549. &&([DFPlayer sharedPlayer].state == DFPlayerStateBuffering
  550. || [DFPlayer sharedPlayer].state == DFPlayerStatePlaying)
  551. ){
  552. [[DFPlayer sharedPlayer] df_pause];
  553. [[audioPlayingView sharedInstance] setAudioPlayingStateFunBy:NO];
  554. }
  555. if(ksharedAppDelegate.isDidShowPwdType){
  556. KWeakSelf
  557. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  558. [weakSelf LogoutByOtherFun];
  559. HLog(@"weakSelf LogoutByOtherFun")
  560. });
  561. return;
  562. }
  563. _isWaitShowLogoutAlert = NO;;
  564. /*弹窗提示重启*/
  565. //KWeakSelf
  566. logoutAlertVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"single_sign_on_Tips_logout",nil)
  567. msg:LogoutTimerStr
  568. imageStr:@""
  569. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  570. okTitle:loginAgainStr isOkBtnHighlight:isOkBtnHighlight
  571. didClickOk:^{
  572. //[weakSelf tryAgain];
  573. //[[webSocketManager shareInstance] WebSocketNeedRelinkFun];
  574. self->_isLogoutByOtherType = NO;
  575. self->logoutAlertVC = nil;
  576. [[NSNotificationCenter defaultCenter] postNotificationName:lockBypwdNotification object:nil];
  577. } didClickCancel:^{
  578. exit(0);/*强制退出app*/
  579. }];
  580. logoutAlertVC.modalPresentationStyle = UIModalPresentationCustom;
  581. [[iTools appRootViewController] presentViewController:logoutAlertVC animated:YES completion:^{
  582. self->logoutAlertVC.view.superview.backgroundColor = [UIColor clearColor];
  583. }];
  584. }
  585. @end