From 8ac8b6432aa2b192fb80ab041aabb0d04d83c6af Mon Sep 17 00:00:00 2001 From: kitolog Date: Thu, 29 Mar 2018 09:30:16 +0300 Subject: [PATCH] fixed iOS closing sockets on open timeout --- README.md | 3 ++- package.json | 2 +- plugin.xml | 2 +- src/ios/SocketsForCordova/Classes/SocketAdapter.m | 1 + src/ios/SocketsForCordova/Classes/SocketPlugin.m | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a493f8..6e34e87 100644 --- a/README.md +++ b/README.md @@ -162,4 +162,5 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - 1.5.0 - added iOS open and write timeouts, changed js errors format - 1.5.1 - fixed cordova js bridge implementation - 1.5.2 - fixed iOS open timeout - - 1.5.3 - added Android open and write timeouts \ No newline at end of file + - 1.5.3 - added Android open and write timeouts + - 1.5.4 - fixed iOS closing sockets on open timeout \ No newline at end of file diff --git a/package.json b/package.json index f4ee98c..08aeaca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-socket-tcp", - "version": "1.5.3", + "version": "1.5.4", "description": "This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol. Currently we support these platforms: iOS, Android, WP8.", "cordova": { "platforms": [ diff --git a/plugin.xml b/plugin.xml index bb557ce..7737aad 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ - + SocketsForCordova This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol. diff --git a/src/ios/SocketsForCordova/Classes/SocketAdapter.m b/src/ios/SocketsForCordova/Classes/SocketAdapter.m index fe63191..8922205 100644 --- a/src/ios/SocketsForCordova/Classes/SocketAdapter.m +++ b/src/ios/SocketsForCordova/Classes/SocketAdapter.m @@ -80,6 +80,7 @@ int writeTimeoutSeconds = 5.0; //self.errorEventHandler(@"Socket open timeout", @"openTimeout"); self.openErrorEventHandler(@"Socket open timeout"); openTimer = nil; + [self close]; } -(void)onWriteTimeout:(NSTimer *)timer { diff --git a/src/ios/SocketsForCordova/Classes/SocketPlugin.m b/src/ios/SocketsForCordova/Classes/SocketPlugin.m index b1a32ac..449d19a 100644 --- a/src/ios/SocketsForCordova/Classes/SocketPlugin.m +++ b/src/ios/SocketsForCordova/Classes/SocketPlugin.m @@ -41,11 +41,10 @@ socketAdapter = nil; }; socketAdapter.openErrorEventHandler = ^ void (NSString *error){ + NSLog(@"[NATIVE] openErrorEventHandler"); [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error] callbackId:command.callbackId]; - - socketAdapter = nil; }; socketAdapter.errorEventHandler = ^ void (NSString *error, NSString *errorType){ NSMutableDictionary *errorDictionaryData = [[NSMutableDictionary alloc] init]; @@ -65,6 +64,7 @@ [self dispatchEventWithDictionary:dataDictionary]; }; socketAdapter.closeEventHandler = ^ void (BOOL hasErrors) { + NSLog(@"[NATIVE] closeEventHandler"); NSMutableDictionary *closeDictionaryData = [[NSMutableDictionary alloc] init]; [closeDictionaryData setObject:@"Close" forKey:@"type"]; [closeDictionaryData setObject:(hasErrors == TRUE ? @"true": @"false") forKey:@"hasError"];