From 04125dd98f6c69e3249b8f8c4a7f9cacbe550368 Mon Sep 17 00:00:00 2001 From: "nikita.kosilo" Date: Mon, 19 Oct 2020 20:02:39 +0300 Subject: [PATCH] fixed Android socket errors handling --- README.md | 3 ++- package.json | 2 +- plugin.xml | 2 +- .../blocshop/socketsforcordova/SocketPlugin.java | 14 +++++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ac72e23..e79c2d7 100644 --- a/README.md +++ b/README.md @@ -165,4 +165,5 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - 1.5.3 - added Android open and write timeouts [Android] - 1.5.4 - fixed iOS closing sockets on open timeout [iOS] - 1.6.0 - close old existing sockets on reopen by destination ports. Removed iOS trash sources [iOS, Android] - - 1.7.0 - added codes to error handlers [iOS, Android] \ No newline at end of file + - 1.7.0 - added codes to error handlers [iOS, Android] + - 1.7.1 - error handler bugfixes [Android] \ No newline at end of file diff --git a/package.json b/package.json index 6c8199d..ebe30ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-socket-tcp", - "version": "1.7.0", + "version": "1.7.1", "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": { "platforms": [ diff --git a/plugin.xml b/plugin.xml index 8a07e45..14fa6eb 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,6 +1,6 @@ - + SocketsForCordova This Cordova plugin provides JavaScript API, that allows you to communicate with server through TCP protocol. diff --git a/src/android/src/cz/blocshop/socketsforcordova/SocketPlugin.java b/src/android/src/cz/blocshop/socketsforcordova/SocketPlugin.java index f94550b..bb7808c 100644 --- a/src/android/src/cz/blocshop/socketsforcordova/SocketPlugin.java +++ b/src/android/src/cz/blocshop/socketsforcordova/SocketPlugin.java @@ -278,11 +278,15 @@ public class SocketPlugin extends CordovaPlugin { @Override public void accept(String errorMessage) { - JSONObject event = new JSONObject(); - event.put("errorMessage", errorMessage); - event.put("socketKey", "key"); - event.put("code", 0); - this.openCallbackContext.error(event); + try { + JSONObject event = new JSONObject(); + event.put("errorMessage", errorMessage); + event.put("socketKey", "key"); + event.put("code", 0); + this.openCallbackContext.error(event); + } catch (JSONException e) { + e.printStackTrace(); + } } }