浏览代码

1.被挤下线弹框处理

huangxiaodong 11 月之前
父节点
当前提交
765e56e942

+ 4 - 2
创维盒子/双子星云手机/AppDelegate/Config/Notification.h

@@ -127,11 +127,13 @@
 #pragma mark 安全支付结果通知
 #define NotificationNameBySafepayResult  @"SafepayResult" //
 
-/*显示声音和画面 */
-#define ShowImgAndVoiceNotification                 @"ShowImgAndVoiceNot"
+/*输入密码完成 ->显示声音和画面 */
+#define didInputPWDNotification                 @"didInputPWDNot"
 //显示密码页面  即不可展示图片和声音
 #define ShowPwdVCNotification                 @"ShowPwdVCNot"
 
+/*被挤下线通知*/
+#define logoutByOtherNotification                 @"logoutByOtherNot"
 
 #pragma mark 下载其它类型文件完成
 //#define NotLoadOtherDataFinished  @"loadOtherDataFinished"

+ 1 - 1
创维盒子/双子星云手机/AppDelegate/SceneDelegate.m

@@ -814,7 +814,7 @@
         if(!isPrivacyMode)
         {
             [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
-            [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
             return;
         }
     }

+ 3 - 1
创维盒子/双子星云手机/Class/Calculator/CalculatorViewController.m

@@ -414,8 +414,10 @@
                     [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
                     
                     [self.view removeFromSuperview];
+                    //被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
+                    [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
                     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-                        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+                        [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
                     });
                 }
 

+ 3 - 1
创维盒子/双子星云手机/Class/Controller/HWWebViewController.m

@@ -358,8 +358,10 @@
                         [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
                         
                         [self.view removeFromSuperview];
+                        //被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
+                        [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
                         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-                            [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+                            [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
                         });
                     }
                     else if([text isEqualToString:keyToForgetPwd]){

+ 1 - 1
创维盒子/双子星云手机/Class/Guide/GuideViewController.m

@@ -94,7 +94,7 @@
                 [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
                
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-                    [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+                    [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
                 });
                 
                 return;

+ 3 - 1
创维盒子/双子星云手机/Class/Guide/inputPWDViewController.m

@@ -528,8 +528,10 @@
         [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
     }
    
+    //被别的设备挤下线 重新链接 如果是链接中 走这个函数会被return
+    [[webSocketManager shareInstance] opencommandChannelManagerrc_openURL];
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
     });
     
     //view 加载在windows上

+ 2 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+AdjustBtnFrame.h

@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
 /**3s后 圆形浮标自动靠边隐藏*/
 @property NSInteger          adjustTime;
 
+- (void)playerViewControlBtnTouchBegan;
+- (void)playerViewControlBtnTouchEnd;
 - (void)extensionAdjustBtnFrameCheckAdjustTime;
 
 @end

+ 0 - 3
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+AppDelegate.m

@@ -77,9 +77,6 @@
     
     self.nowSSid = tempSSID;
     
-    if(self->logoutAlertVC){
-        return;
-    }
     
     if ([wattingView superview])
     {

+ 3 - 3
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm

@@ -30,9 +30,9 @@
 - (void)CommonAlertokBtnClickPressed{
     //HLog("11111");
     
-    if(self->logoutAlertVC){
-        self->logoutAlertVC = nil;
-    }
+//    if(self->logoutAlertVC){
+//        self->logoutAlertVC = nil;
+//    }
     
     self.isLoginAgainType = YES;
     

+ 0 - 3
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

@@ -67,9 +67,6 @@
     UIView *wattingView;
     USBInsertPopView *curUSBInsertPopV;
     
-    /*弹窗提示重启*/
-    ComontAlretViewController *logoutAlertVC;
-    
     //下载nas相关
     customDownloadOperation* curDownloadmodel;
     

+ 4 - 55
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -1507,52 +1507,6 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     [self disconnectVideoServer];
     
     _canShowImgAndVoiceType = NO;
-    
-    //yyyy-MM-dd HH:mm:ss
-    NSString*dateStr = [iTools getNowTimeString2];
-    if(dateStr && dateStr.length == 19){
-        dateStr = [dateStr substringWithRange:NSMakeRange(11, 5)];
-    }
-    
-    if(!_needShowLogoutDelayType){
-        _LogoutTimerStr = [[NSString alloc] initWithFormat:@"%@%@%@",NSLocalizedString(@"single_sign_on_Tips_one",nil),dateStr,NSLocalizedString(@"single_sign_on_Tips_two",nil)];
-    }
-    
-    
-    if(_isPwdVCShow){
-        _needShowLogoutDelayType = YES;
-        return;
-    }
-    
-    _needShowLogoutDelayType = NO;
-    
-    NSString * loginAgainStr = NSLocalizedString(@"single_sign_on_login_again",nil);
-    BOOL isOkBtnHighlight = YES;
-    if(![connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode){
-        loginAgainStr = @"";
-        isOkBtnHighlight = NO;
-    }
-    
-    /*弹窗提示重启*/
-    KWeakSelf
-    logoutAlertVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"single_sign_on_Tips_logout",nil)
-                                                                                     msg:_LogoutTimerStr
-                                                                                imageStr:nil
-                                                                             cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
-                                                                                 okTitle:loginAgainStr isOkBtnHighlight:isOkBtnHighlight
-                                                                             didClickOk:^{
-        [weakSelf tryAgain];
-        [[webSocketManager shareInstance] WebSocketNeedRelinkFun];
-        
-    } didClickCancel:^{
-        
-    }];
-    logoutAlertVC.modalPresentationStyle = UIModalPresentationCustom;
-    logoutAlertVC.delegate = self;
-    [[iTools appRootViewController] presentViewController:logoutAlertVC animated:YES completion:^{
-        self->logoutAlertVC.view.superview.backgroundColor = [UIColor clearColor];
-    }];
-    
     _isLoginAgainType = YES;
 }
 
@@ -1566,10 +1520,6 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 {
     _isPwdVCShow = NO;
     
-    if(logoutAlertVC){
-        return;
-    }
-    
     [self setShowImgAndVoiceTypeFun:YES];
     
     if(_needShowLogoutDelayType){
@@ -1592,10 +1542,6 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 {
     if(isCan){//判断当前是否为最前面 才能播放
         
-        if(self->logoutAlertVC){
-            return;
-        }
-        
         if(_isLoginAgainType ){
             [self tryAgain];
             
@@ -2058,11 +2004,14 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerViewControlBtnTouchBegan) name:PlayerViewControlBtnTouchBeganNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerViewControlBtnTouchEnd) name:PlayerViewControlBtnTouchEndNotification object:nil];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowImgAndVoiceTypeFun) name:ShowImgAndVoiceNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowImgAndVoiceTypeFun) name:didInputPWDNotification object:nil];
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowPwdVCTypeFun) name:ShowPwdVCNotification object:nil];
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPlayerFullScreenNotFun)  name:setPlayerFullScreenNotification  object:nil];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(LogoutByOtherFun)  name:logoutByOtherNotification  object:nil];
+    
 }
 
 - (void)removeNSNotification

+ 1 - 0
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager.h

@@ -70,6 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property(nonatomic,assign)BOOL isRebootIngType;//是否重启中
 @property(nonatomic,assign)BOOL isResetingType;//是否恢复出厂中
 @property(nonatomic,assign)BOOL isChangeBoxType;//是否更换盒子
+@property(nonatomic,assign)BOOL isLogoutByOtherType;//被挤下线
 
 //链接websocket
 - (void)opencommandChannelManagerrc_openURL;

+ 69 - 5
创维盒子/双子星云手机/cloudPhone/websocket/webSocketManager.m

@@ -13,10 +13,12 @@
 #import "webSocketManager+upLoadFile.h"
 #import "webSocketManager+backupsFile.h"
 #import "errorAlertTool.h"
+#import "RcGameWQKeyChain.h"
 
 @interface webSocketManager ()
 {
     NSMutableArray *commandSendCheckArr;//需要检测任务是否发出的的指令
+    ComontAlretViewController *logoutAlertVC;
 }
 
 @property(copy,nonatomic)NSString *curIp;
@@ -163,7 +165,7 @@ static webSocketManager *webSocketManagerInstance = nil;
                         NSString * dataStr = (NSString*)data;
                         if([dataStr isEqualToString:@"offline_notification"]){
                             HLog(@"被别人挤下线了");
-                            //[weakSelf LogoutByOtherFun];
+                            [weakSelf LogoutByOtherFun];
                         }
                          
                          return;
@@ -430,7 +432,7 @@ static webSocketManager *webSocketManagerInstance = nil;
 {
     if(commandSendCheckArr && commandSendCheckArr.count >0){
         for (commandSendCheckModel *model in commandSendCheckArr) {
-            if(model.reSendNum < 3){
+            if(model.reSendNum < 2){
                 model.reSendNum ++;
                 if(model.commandStr){
                     [self send_data:model.commandStr];
@@ -499,9 +501,15 @@ static webSocketManager *webSocketManagerInstance = nil;
     {
         [self getSysInfoFun];
         
-//        NSString *commondStr  = @"{\"type\":\"forwardMsg\",\"data\":\"offline_notification\"}";
-//        [self send_data:commondStr];
-//        [self addCommandSendTaskFunWithType:@"offline_notification" WithCommandStr:commondStr];
+        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 = true;
         
@@ -938,4 +946,60 @@ static webSocketManager *webSocketManagerInstance = nil;
     [self send_data:commondStr];
 }
 
+#pragma mark 单点登录被挤下线弹框
+- (void)LogoutByOtherFun
+{
+    if(logoutAlertVC){
+        return;
+    }
+    
+    //通知音视频断开链接
+    [[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(![connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode){
+        loginAgainStr = @"";
+        isOkBtnHighlight = NO;
+    }
+    
+    _isLogoutByOtherType = YES;
+    
+    //被挤下线 ws断开
+    [self.commandChannelManager rc_close];
+    self.commandChannelManager = nil;
+    
+    /*弹窗提示重启*/
+    //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;
+        [[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