Переглянути джерело

1.webrtc链接监听问题

huangxiaodong 3 днів тому
батько
коміт
f036e1b733

+ 17 - 5
创维盒子/code/mine/mineViewController.m

@@ -44,7 +44,7 @@
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PCLoginDidPopFun)  name:showTabbarNotification  object:nil];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setDataFun)  name:webRtcLinkStateChangeNotification  object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSetDataFun)  name:webRtcLinkStateChangeNotification  object:nil];
     
     
     [self drawAnyView];
@@ -500,6 +500,13 @@
 }
 
 
+- (void)mainSetDataFun
+{
+    KWeakSelf
+    mainBlock(^{
+        [weakSelf setDataFun];
+    });
+}
 
 #pragma mark 数据设置
 - (void)setDataFun
@@ -527,11 +534,16 @@
         NetButText = NSLocalizedString(@"mine_net_WAN",nil);
     }
     
-    RTCDataChannelState state = [webRtcManager shareManager].channelState;
+    RTCDataChannelState channelState = [webRtcManager shareManager].channelState;
+    RTCIceConnectionState ConnectionState = [webRtcManager shareManager].ConnectionState;
     
-    if(state != RTCDataChannelStateOpen
-       ||!ksharedAppDelegate.isWebSockLinkOKAginType//断开了
-       )
+    if((ConnectionState == RTCIceConnectionStateConnected
+       && channelState == RTCDataChannelStateOpen)
+       //&& !ksharedAppDelegate.isWebSockLinkOKAginType//断开了
+       ){
+        
+    }
+    else
     {
         NetButText = NSLocalizedString(@"mine_net_unLink",nil);
     }

+ 4 - 2
创维盒子/code/webRtc/webRtcManager/webRtcManager.m

@@ -997,6 +997,7 @@
     switch (state) {
         case RTCIceConnectionStateConnected:{
             //链接成功
+            [[NSNotificationCenter defaultCenter] postNotificationName:webRtcLinkStateChangeNotification object:nil];/*发送通知*/
         }
             break;
         case RTCIceConnectionStateCompleted:
@@ -1005,6 +1006,9 @@
         case RTCIceConnectionStateFailed:
         case RTCIceConnectionStateDisconnected:
         case RTCIceConnectionStateClosed:{
+            
+            [[NSNotificationCenter defaultCenter] postNotificationName:webRtcLinkStateChangeNotification object:nil];/*发送通知*/
+            
             if(!_didReportWebRtcFailType && state == RTCIceConnectionStateFailed){//还没上报过通道链接情况
                 _didReportWebRtcFailType = YES;
 //                KWeakSelf
@@ -1057,8 +1061,6 @@
             break;
         case RTCDataChannelStateClosed:
             {
-                [[NSNotificationCenter defaultCenter] postNotificationName:webRtcLinkStateChangeNotification object:nil];/*发送通知*/
-                
                 //链接断开
                 [self relinkWebRtcFun];
             }