From 6adfa2af5ff051575ec70fd2c4fea8bcf6597311 Mon Sep 17 00:00:00 2001 From: Brandon Kase Date: Wed, 2 Jan 2013 16:05:55 -0500 Subject: [PATCH] Fixed crash on a no-argument message If a message from the socket.io server is emitted with no arguments, it now is properly received --- src/com/codebutler/android_websockets/SocketIOClient.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/codebutler/android_websockets/SocketIOClient.java b/src/com/codebutler/android_websockets/SocketIOClient.java index af461fb..615f70a 100644 --- a/src/com/codebutler/android_websockets/SocketIOClient.java +++ b/src/com/codebutler/android_websockets/SocketIOClient.java @@ -116,7 +116,12 @@ public void onMessage(String message) { final String dataString = parts[3]; JSONObject data = new JSONObject(dataString); String event = data.getString("name"); - JSONArray args = data.getJSONArray("args"); + JSONArray args; + try { + args = data.getJSONArray("args"); + } catch (JSONException e) { + args = new JSONArray(); + } if (!"".equals(messageId)) { mSendHandler.post(new Runnable() { @Override