Small fixes and cleanup

This commit is contained in:
Martin Obrátil 2014-11-09 20:51:51 +01:00
parent 94d7be1791
commit 582f667e65
3 changed files with 4 additions and 16 deletions

View File

@ -37,7 +37,6 @@ BOOL wasOpenned = FALSE;
[inputStream open]; [inputStream open];
outputStream = (__bridge NSOutputStream *)writeStream; outputStream = (__bridge NSOutputStream *)writeStream;
//[outputStream setDelegate:self];
[outputStream open]; [outputStream open];
[self performSelectorOnMainThread:@selector(runReadLoop) withObject:nil waitUntilDone:NO]; [self performSelectorOnMainThread:@selector(runReadLoop) withObject:nil waitUntilDone:NO];
@ -125,13 +124,11 @@ BOOL wasOpenned = FALSE;
case NSStreamEventHasBytesAvailable: { case NSStreamEventHasBytesAvailable: {
if(stream == inputStream) { if(stream == inputStream) {
uint8_t buf[65535]; uint8_t buf[65535];
unsigned int len = 0; long len = [inputStream read:buf maxLength:65535];
len = [inputStream read:buf maxLength:65535];
NSLog(@"%d", len);
if(len > 0) { if(len > 0) {
NSMutableArray *dataArray = [[NSMutableArray alloc] init]; NSMutableArray *dataArray = [[NSMutableArray alloc] init];
for (int i = 0; i < len; i++) { for (long i = 0; i < len; i++) {
[dataArray addObject:[NSNumber numberWithUnsignedChar:buf[i]]]; [dataArray addObject:[NSNumber numberWithUnsignedChar:buf[i]]];
} }
@ -184,6 +181,7 @@ BOOL wasOpenned = FALSE;
} }
- (void)close { - (void)close {
self.closeEventHandler(FALSE);
[self closeOutputStream]; [self closeOutputStream];
[self closeInputStream]; [self closeInputStream];
} }

View File

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

View File

@ -5,15 +5,6 @@
@implementation SocketPlugin : CDVPlugin @implementation SocketPlugin : CDVPlugin
- (void) create : (CDVInvokedUrlCommand*) command {
//NSString* socketKey = [command.arguments objectAtIndex : 0];
[self.commandDelegate
sendPluginResult: [CDVPluginResult resultWithStatus : CDVCommandStatus_OK]
callbackId: command.callbackId];
}
- (void) connect : (CDVInvokedUrlCommand*) command { - (void) connect : (CDVInvokedUrlCommand*) command {
NSString *socketKey = [command.arguments objectAtIndex:0]; NSString *socketKey = [command.arguments objectAtIndex:0];