socket设置 review by 盖建秋
Showing
1 changed file
with
9 additions
and
2 deletions
@@ -151,7 +151,6 @@ | @@ -151,7 +151,6 @@ | ||
151 | [self initUI]; | 151 | [self initUI]; |
152 | [self loadChannelData]; | 152 | [self loadChannelData]; |
153 | [self setUpPush]; | 153 | [self setUpPush]; |
154 | - _socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; | ||
155 | _currentRetryCount = 0; | 154 | _currentRetryCount = 0; |
156 | DLog(@"=====%@",[_livePush getSDKVersion]); | 155 | DLog(@"=====%@",[_livePush getSDKVersion]); |
157 | } | 156 | } |
@@ -442,6 +441,12 @@ | @@ -442,6 +441,12 @@ | ||
442 | 441 | ||
443 | 442 | ||
444 | - (void)connectSocket { | 443 | - (void)connectSocket { |
444 | + if (_socket) { | ||
445 | + [_socket disconnect]; | ||
446 | + _socket = nil; | ||
447 | + } | ||
448 | + _socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; | ||
449 | + | ||
445 | [_socket connectToHost:_socketService.socketLiveHost onPort:_socketService.socketLivePort error:nil]; | 450 | [_socket connectToHost:_socketService.socketLiveHost onPort:_socketService.socketLivePort error:nil]; |
446 | } | 451 | } |
447 | 452 | ||
@@ -477,7 +482,7 @@ | @@ -477,7 +482,7 @@ | ||
477 | dispatch_async(dispatch_get_main_queue(), ^{ | 482 | dispatch_async(dispatch_get_main_queue(), ^{ |
478 | if (tag == 1) {//登录成功了之后才继续后面的。。。。 | 483 | if (tag == 1) {//登录成功了之后才继续后面的。。。。 |
479 | [self socketSendEndNotify]; | 484 | [self socketSendEndNotify]; |
480 | - _socketTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(socketSendEndNotify) userInfo:nil repeats:YES]; | 485 | + _socketTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(socketSendEndNotify) userInfo:nil repeats:YES]; |
481 | } | 486 | } |
482 | }); | 487 | }); |
483 | } | 488 | } |
@@ -495,9 +500,11 @@ | @@ -495,9 +500,11 @@ | ||
495 | DLog(@"通知结束成功"); | 500 | DLog(@"通知结束成功"); |
496 | [self toastTip:@"通知结束成功"]; | 501 | [self toastTip:@"通知结束成功"]; |
497 | [sock disconnect]; | 502 | [sock disconnect]; |
503 | + _socket = nil; | ||
498 | [self loadChannelData];//防止主播再次进入同一间房间。 | 504 | [self loadChannelData];//防止主播再次进入同一间房间。 |
499 | _inPushing = NO; | 505 | _inPushing = NO; |
500 | [_socketTimer invalidate]; | 506 | [_socketTimer invalidate]; |
507 | + _socketTimer = nil; | ||
501 | [self stopRtmp]; | 508 | [self stopRtmp]; |
502 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging]; | 509 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging]; |
503 | // [self.socketService endPaly:_timeLabel.text]; | 510 | // [self.socketService endPaly:_timeLabel.text]; |
-
Please register or login to post a comment