Fixed ios api
This commit is contained in:
parent
d13b37b960
commit
5083cfe79b
@ -4,7 +4,7 @@
|
|||||||
@public
|
@public
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connect:(NSString *)host port:(NSNumber*)port;
|
- (void)open:(NSString *)host port:(NSNumber*)port;
|
||||||
- (void)write:(NSArray *)dataArray;
|
- (void)write:(NSArray *)dataArray;
|
||||||
- (void)shutdownWrite;
|
- (void)shutdownWrite;
|
||||||
- (void)close;
|
- (void)close;
|
||||||
|
@ -13,7 +13,7 @@ BOOL wasOpenned = FALSE;
|
|||||||
|
|
||||||
@implementation SocketAdapter
|
@implementation SocketAdapter
|
||||||
|
|
||||||
- (void)connect:(NSString *)host port:(NSNumber*)port {
|
- (void)open:(NSString *)host port:(NSNumber*)port {
|
||||||
|
|
||||||
NSLog(@"Setting up connection to %@ : %@", host, [port stringValue]);
|
NSLog(@"Setting up connection to %@ : %@", host, [port stringValue]);
|
||||||
|
|
||||||
@ -150,8 +150,6 @@ BOOL wasOpenned = FALSE;
|
|||||||
{
|
{
|
||||||
NSLog(@"Stream event error: %@", [[stream streamError] localizedDescription]);
|
NSLog(@"Stream event error: %@", [[stream streamError] localizedDescription]);
|
||||||
|
|
||||||
[self close];
|
|
||||||
|
|
||||||
if (wasOpenned) {
|
if (wasOpenned) {
|
||||||
self.errorEventHandler([[stream streamError] localizedDescription]);
|
self.errorEventHandler([[stream streamError] localizedDescription]);
|
||||||
self.closeEventHandler(TRUE);
|
self.closeEventHandler(TRUE);
|
||||||
@ -160,6 +158,7 @@ BOOL wasOpenned = FALSE;
|
|||||||
self.errorEventHandler([[stream streamError] localizedDescription]);
|
self.errorEventHandler([[stream streamError] localizedDescription]);
|
||||||
self.openErrorEventHandler([[stream streamError] localizedDescription]);
|
self.openErrorEventHandler([[stream streamError] localizedDescription]);
|
||||||
}
|
}
|
||||||
|
//[self closeStreams];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -182,6 +181,10 @@ BOOL wasOpenned = FALSE;
|
|||||||
|
|
||||||
- (void)close {
|
- (void)close {
|
||||||
self.closeEventHandler(FALSE);
|
self.closeEventHandler(FALSE);
|
||||||
|
[self closeStreams];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)closeStreams {
|
||||||
[self closeOutputStream];
|
[self closeOutputStream];
|
||||||
[self closeInputStream];
|
[self closeInputStream];
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
NSMutableDictionary *socketAdapters;
|
NSMutableDictionary *socketAdapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) connect: (CDVInvokedUrlCommand *) command;
|
-(void) open: (CDVInvokedUrlCommand *) command;
|
||||||
-(void) write: (CDVInvokedUrlCommand *) command;
|
-(void) write: (CDVInvokedUrlCommand *) command;
|
||||||
-(void) close: (CDVInvokedUrlCommand *) command;
|
-(void) close: (CDVInvokedUrlCommand *) command;
|
||||||
-(void) setOptions: (CDVInvokedUrlCommand *) command;
|
-(void) setOptions: (CDVInvokedUrlCommand *) command;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
@implementation SocketPlugin : CDVPlugin
|
@implementation SocketPlugin : CDVPlugin
|
||||||
|
|
||||||
- (void) connect : (CDVInvokedUrlCommand*) command {
|
- (void) open : (CDVInvokedUrlCommand*) command {
|
||||||
|
|
||||||
NSString *socketKey = [command.arguments objectAtIndex:0];
|
NSString *socketKey = [command.arguments objectAtIndex:0];
|
||||||
NSString *host = [command.arguments objectAtIndex:1];
|
NSString *host = [command.arguments objectAtIndex:1];
|
||||||
@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
[self.commandDelegate runInBackground:^{
|
[self.commandDelegate runInBackground:^{
|
||||||
@try {
|
@try {
|
||||||
[socketAdapter connect:host port:port];
|
[socketAdapter open:host port:port];
|
||||||
}
|
}
|
||||||
@catch (NSException *e) {
|
@catch (NSException *e) {
|
||||||
[self.commandDelegate
|
[self.commandDelegate
|
||||||
|
Loading…
Reference in New Issue
Block a user