Fixed cordova js bridge implementation, fixed iOS open timeout

This commit is contained in:
kitolog 2018-03-27 11:14:43 +03:00
parent ebe8bc7bd3
commit 26a14948e3
6 changed files with 217 additions and 206 deletions

View File

@ -158,5 +158,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## What's new ## What's new
1.2.3 - fixed ios socket closing crashes 1.2.3 - fixed iOS socket closing crashes
1.5.0 - added ios open and write timeouts, changed js errors format 1.5.0 - added iOS and Android open and write timeouts, changed js errors format
1.5.1 - fixed cordova js bridge implementation
1.5.2 - fixed iOS open timeout

View File

@ -1,6 +1,6 @@
{ {
"name": "cordova-plugin-socket-tcp", "name": "cordova-plugin-socket-tcp",
"version": "1.5.0", "version": "1.5.2",
"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.", "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": { "cordova": {
"platforms": [ "platforms": [

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-socket-tcp" version="1.5.0"> <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-socket-tcp" version="1.5.2">
<name>SocketsForCordova</name> <name>SocketsForCordova</name>
<description> <description>
This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol. This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol.
@ -49,7 +49,6 @@
<!--<framework src="CoreGraphics.framework" />--> <!--<framework src="CoreGraphics.framework" />-->
</platform> </platform>
<!-- wp8 --> <!-- wp8 -->
<platform name="wp8"> <platform name="wp8">
<config-file target="config.xml" parent="/*"> <config-file target="config.xml" parent="/*">
@ -65,7 +64,4 @@
<source-file src="src/wp8/src/SocketEvent.cs" target-dir="src" /> <source-file src="src/wp8/src/SocketEvent.cs" target-dir="src" />
<source-file src="src/wp8/src/SocketStorage.cs" target-dir="src" /> <source-file src="src/wp8/src/SocketStorage.cs" target-dir="src" />
</platform> </platform>
</plugin> </plugin>

View File

@ -1,4 +1,3 @@
cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, module) {
/** /**
* Copyright (c) 2015, Blocshop s.r.o. * Copyright (c) 2015, Blocshop s.r.o.
* All rights reserved. * All rights reserved.
@ -43,8 +42,10 @@ cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, mo
Socket.prototype.open = function (host, port, success, error) { Socket.prototype.open = function (host, port, success, error) {
success = success || function() { }; success = success || function () {
error = error || function() { }; };
error = error || function () {
};
if (!this._ensureState(Socket.State.CLOSED, error)) { if (!this._ensureState(Socket.State.CLOSED, error)) {
return; return;
@ -92,13 +93,19 @@ cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, mo
}, },
CORDOVA_SERVICE_NAME, CORDOVA_SERVICE_NAME,
"open", "open",
[ this.socketKey, host, port ]); [
this.socketKey,
host,
port
]);
}; };
Socket.prototype.write = function (data, success, error) { Socket.prototype.write = function (data, success, error) {
success = success || function() { }; success = success || function () {
error = error || function() { }; };
error = error || function () {
};
if (!this._ensureState(Socket.State.OPENED, error)) { if (!this._ensureState(Socket.State.OPENED, error)) {
return; return;
@ -113,13 +120,18 @@ cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, mo
error, error,
CORDOVA_SERVICE_NAME, CORDOVA_SERVICE_NAME,
"write", "write",
[ this.socketKey, dataToWrite ]); [
this.socketKey,
dataToWrite
]);
}; };
Socket.prototype.shutdownWrite = function (success, error) { Socket.prototype.shutdownWrite = function (success, error) {
success = success || function() { }; success = success || function () {
error = error || function() { }; };
error = error || function () {
};
if (!this._ensureState(Socket.State.OPENED, error)) { if (!this._ensureState(Socket.State.OPENED, error)) {
return; return;
@ -135,8 +147,10 @@ cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, mo
Socket.prototype.close = function (success, error) { Socket.prototype.close = function (success, error) {
success = success || function() { }; success = success || function () {
error = error || function() { }; };
error = error || function () {
};
if (!this._ensureState(Socket.State.OPENED, error)) { if (!this._ensureState(Socket.State.OPENED, error)) {
return; return;
@ -217,5 +231,3 @@ cordova.define("cordova-plugin-socket-tcp.Socket", function(require, exports, mo
} }
module.exports = Socket; module.exports = Socket;
});

BIN
src/ios/.DS_Store vendored

Binary file not shown.

View File

@ -77,7 +77,8 @@ int writeTimeoutSeconds = 5.0;
-(void)onOpenTimeout:(NSTimer *)timer { -(void)onOpenTimeout:(NSTimer *)timer {
NSLog(@"[NATIVE] Open timeout: %d", openTimeoutSeconds); NSLog(@"[NATIVE] Open timeout: %d", openTimeoutSeconds);
self.errorEventHandler(@"Socket open timeout", @"openTimeout"); //self.errorEventHandler(@"Socket open timeout", @"openTimeout");
self.openErrorEventHandler(@"Socket open timeout");
openTimer = nil; openTimer = nil;
} }