From 6782887878ea4a2503e15ef8f0c63ec7ba35a170 Mon Sep 17 00:00:00 2001 From: xuemh Date: Fri, 17 Aug 2018 06:58:50 +0800 Subject: [PATCH] =?UTF-8?q?socket=E4=BD=BF=E7=94=A8=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E6=97=B6=E8=B0=83=E7=94=A8close=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../leftcontrollers/ConnectHotpotViewController.m | 6 +----- Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m index 7b37132..575f98c 100644 --- a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m +++ b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m @@ -43,11 +43,6 @@ UITapGestureRecognizer *fiveTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(test)]; fiveTapGesture.numberOfTapsRequired = 5; [self.containerView addGestureRecognizer:fiveTapGesture]; - - IFishUDPHelperBackMsgModel *model = [IFishUDPHelperBackMsgModel new]; - model.result = @"01"; - model.senderMacAddress = @"123456778"; - [self udpHelperCommandExecutedSuccess:model]; } - (void)test { @@ -155,6 +150,7 @@ [self appendTrakContent:@"=================收到设备答复==================="]; [self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]]; [self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]]; + [[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand]; [self bindDeviceWithSsid:backModel.senderMacAddress]; } diff --git a/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m b/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m index 60157c4..2dc9237 100644 --- a/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m +++ b/Ifish/controllers/leftcontrollers/IFishHotpotUDPHelper.m @@ -154,6 +154,7 @@ AppDelegate *app =(AppDelegate*)[UIApplication sharedApplication].delegate; [app.window makeToast:[NSString stringWithFormat:@"收到答复:%@", result]]; } + [self.clientSocket close]; [self.loopTimer invalidate]; return YES; @@ -161,6 +162,7 @@ -(void)onUdpSocketDidClose:(AsyncUdpSocket *)sock{ + [self.clientSocket close]; [self.loopTimer invalidate]; NSLog(@"关闭"); } @@ -176,12 +178,15 @@ NSLog(@"dueToError%@",error); [self postmsg:error.localizedDescription]; + + [self.clientSocket close]; [self.loopTimer invalidate]; } -(void)dealloc{ + [self.clientSocket close]; [self.loopTimer invalidate]; }