socket未连接优化
This commit is contained in:
parent
90bcb3e43a
commit
64d5967585
|
|
@ -15869,7 +15869,7 @@
|
|||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
DEVELOPMENT_TEAM = WFX8GD5HFX;
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
|
@ -15988,7 +15988,7 @@
|
|||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
DEVELOPMENT_TEAM = WFX8GD5HFX;
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
|
|
|
|||
|
|
@ -321,14 +321,28 @@ Copy NSString *deviceId;
|
|||
{
|
||||
return;
|
||||
}
|
||||
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
||||
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||
self.HUD.labelText = msg;
|
||||
if ([msg containsString:@"Socket连接失败"])
|
||||
{
|
||||
[self.HUD hide:YES afterDelay:5];
|
||||
[self.HUD hide:YES afterDelay:3];
|
||||
[self endProgress];
|
||||
[self.progressView endProgressWithString:@"连接失败"];
|
||||
if (self.retryTimes<10)
|
||||
{
|
||||
self.retryTimes++;
|
||||
[self.progressView endProgressWithString:@"自动重试..."];
|
||||
WEAK_SELF;
|
||||
[[IFishHotpotUDPHelper sharedInstance] closeComplete:^{
|
||||
[weakSelf sendToDeviceWithSSIDName:weakSelf.wifiName andSSIDPWD:weakSelf.wifiPassword];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.progressView endProgressWithString:@"连接结束"];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-(void)endProgress{
|
||||
|
|
|
|||
|
|
@ -29,5 +29,6 @@
|
|||
- (void)broadCastHotspotConnectCommandWith:(NSString *)ssidName pwd:(NSString *)pwd;
|
||||
- (void)broadCastRestartCommand;
|
||||
- (void)broadCastRestCommand;
|
||||
-(void)closeComplete:(void(^)(void))block;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
@property (nonatomic, strong) NSTimer *loopTimer;
|
||||
|
||||
@property (nonatomic, assign) int tag;
|
||||
@property (nonatomic, copy) void(^closeBlock)(void);
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -139,6 +142,16 @@
|
|||
[self postmsg:@"发送失败"];
|
||||
}
|
||||
}
|
||||
- (void)closeComplete:(void (^)(void))block
|
||||
{
|
||||
self.closeBlock = block;
|
||||
if(self.loopTimer)
|
||||
{
|
||||
[self.loopTimer invalidate];
|
||||
self.loopTimer=nil;
|
||||
}
|
||||
[self.clientSocket close];
|
||||
}
|
||||
|
||||
-(BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port
|
||||
{
|
||||
|
|
@ -161,6 +174,9 @@
|
|||
|
||||
-(void)onUdpSocketDidClose:(AsyncUdpSocket *)sock{
|
||||
[self postmsg:@"连接关闭"];
|
||||
if (self.closeBlock) {
|
||||
self.closeBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue