All blocking calls in ios plugin now runs in background thread.
This commit is contained in:
parent
c74a2ee950
commit
9429adb034
@ -66,37 +66,41 @@
|
|||||||
|
|
||||||
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
||||||
|
|
||||||
@try {
|
[self.commandDelegate runInBackground:^{
|
||||||
[socket connect:host port:port];
|
@try {
|
||||||
[self.commandDelegate
|
[socket connect:host port:port];
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
@catch (NSException *e) {
|
}
|
||||||
[self.commandDelegate
|
@catch (NSException *e) {
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) write:(CDVInvokedUrlCommand *) command {
|
- (void) write:(CDVInvokedUrlCommand *) command {
|
||||||
|
|
||||||
NSString* socketKey = [command.arguments objectAtIndex:0];
|
NSString* socketKey = [command.arguments objectAtIndex:0];
|
||||||
NSArray *data = [command.arguments objectAtIndex:1];
|
NSArray *data = [command.arguments objectAtIndex:1];
|
||||||
|
|
||||||
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
||||||
|
|
||||||
@try {
|
[self.commandDelegate runInBackground:^{
|
||||||
[socket write:data];
|
@try {
|
||||||
[self.commandDelegate
|
[socket write:data];
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
@catch (NSException *e) {
|
}
|
||||||
[self.commandDelegate
|
@catch (NSException *e) {
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) close:(CDVInvokedUrlCommand *) command {
|
- (void) close:(CDVInvokedUrlCommand *) command {
|
||||||
@ -105,17 +109,19 @@
|
|||||||
|
|
||||||
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
SocketAdapter *socket = [self getSocketAdapter:socketKey];
|
||||||
|
|
||||||
@try {
|
[self.commandDelegate runInBackground:^{
|
||||||
[socket close];
|
@try {
|
||||||
[self.commandDelegate
|
[socket close];
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
@catch (NSException *e) {
|
}
|
||||||
[self.commandDelegate
|
@catch (NSException *e) {
|
||||||
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
[self.commandDelegate
|
||||||
callbackId:command.callbackId];
|
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:e.reason]
|
||||||
}
|
callbackId:command.callbackId];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setOptions: (CDVInvokedUrlCommand *) command {
|
- (void) setOptions: (CDVInvokedUrlCommand *) command {
|
||||||
|
Loading…
Reference in New Issue
Block a user