Fixed ios api

This commit is contained in:
Martin Obrátil 2014-11-12 16:40:46 +01:00
parent d13b37b960
commit 5083cfe79b
4 changed files with 392 additions and 389 deletions

View File

@ -4,7 +4,7 @@
@public
}
- (void)connect:(NSString *)host port:(NSNumber*)port;
- (void)open:(NSString *)host port:(NSNumber*)port;
- (void)write:(NSArray *)dataArray;
- (void)shutdownWrite;
- (void)close;

View File

@ -13,7 +13,7 @@ BOOL wasOpenned = FALSE;
@implementation SocketAdapter
- (void)connect:(NSString *)host port:(NSNumber*)port {
- (void)open:(NSString *)host port:(NSNumber*)port {
NSLog(@"Setting up connection to %@ : %@", host, [port stringValue]);
@ -150,8 +150,6 @@ BOOL wasOpenned = FALSE;
{
NSLog(@"Stream event error: %@", [[stream streamError] localizedDescription]);
[self close];
if (wasOpenned) {
self.errorEventHandler([[stream streamError] localizedDescription]);
self.closeEventHandler(TRUE);
@ -160,6 +158,7 @@ BOOL wasOpenned = FALSE;
self.errorEventHandler([[stream streamError] localizedDescription]);
self.openErrorEventHandler([[stream streamError] localizedDescription]);
}
//[self closeStreams];
break;
}
default: {
@ -182,6 +181,10 @@ BOOL wasOpenned = FALSE;
- (void)close {
self.closeEventHandler(FALSE);
[self closeStreams];
}
- (void)closeStreams {
[self closeOutputStream];
[self closeInputStream];
}

View File

@ -4,7 +4,7 @@
NSMutableDictionary *socketAdapters;
}
-(void) connect: (CDVInvokedUrlCommand *) command;
-(void) open: (CDVInvokedUrlCommand *) command;
-(void) write: (CDVInvokedUrlCommand *) command;
-(void) close: (CDVInvokedUrlCommand *) command;
-(void) setOptions: (CDVInvokedUrlCommand *) command;

View File

@ -5,7 +5,7 @@
@implementation SocketPlugin : CDVPlugin
- (void) connect : (CDVInvokedUrlCommand*) command {
- (void) open : (CDVInvokedUrlCommand*) command {
NSString *socketKey = [command.arguments objectAtIndex:0];
NSString *host = [command.arguments objectAtIndex:1];
@ -59,7 +59,7 @@
[self.commandDelegate runInBackground:^{
@try {
[socketAdapter connect:host port:port];
[socketAdapter open:host port:port];
}
@catch (NSException *e) {
[self.commandDelegate