use org.json 20090211 for Android support
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -44,7 +44,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.json</groupId>
|
<groupId>org.json</groupId>
|
||||||
<artifactId>json</artifactId>
|
<artifactId>json</artifactId>
|
||||||
<version>20140107</version>
|
<version>20090211</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.github.nkzawa.engineio.client;
|
|||||||
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class HandshakeData {
|
public class HandshakeData {
|
||||||
@@ -11,7 +12,11 @@ public class HandshakeData {
|
|||||||
public long pingInterval;
|
public long pingInterval;
|
||||||
public long pingTimeout;
|
public long pingTimeout;
|
||||||
|
|
||||||
/*package*/ HandshakeData(JSONObject data) {
|
/*package*/ HandshakeData(String data) throws JSONException {
|
||||||
|
this(new JSONObject(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ HandshakeData(JSONObject data) throws JSONException {
|
||||||
JSONArray upgrades = data.getJSONArray("upgrades");
|
JSONArray upgrades = data.getJSONArray("upgrades");
|
||||||
int length = upgrades.length();
|
int length = upgrades.length();
|
||||||
String[] _upgrades = new String[length];
|
String[] _upgrades = new String[length];
|
||||||
|
|||||||
@@ -8,12 +8,15 @@ import com.github.nkzawa.engineio.parser.Packet;
|
|||||||
import com.github.nkzawa.engineio.parser.Parser;
|
import com.github.nkzawa.engineio.parser.Parser;
|
||||||
import com.github.nkzawa.parseqs.ParseQS;
|
import com.github.nkzawa.parseqs.ParseQS;
|
||||||
import com.github.nkzawa.thread.EventThread;
|
import com.github.nkzawa.thread.EventThread;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
@@ -434,7 +437,11 @@ public class Socket extends Emitter {
|
|||||||
this.emit(EVENT_HEARTBEAT);
|
this.emit(EVENT_HEARTBEAT);
|
||||||
|
|
||||||
if (Packet.OPEN.equals(packet.type)) {
|
if (Packet.OPEN.equals(packet.type)) {
|
||||||
this.onHandshake(new HandshakeData(new JSONObject((String)packet.data)));
|
try {
|
||||||
|
this.onHandshake(new HandshakeData((String)packet.data));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
this.emit(EVENT_ERROR, new EngineIOException(e));
|
||||||
|
}
|
||||||
} else if (Packet.PONG.equals(packet.type)) {
|
} else if (Packet.PONG.equals(packet.type)) {
|
||||||
this.setPing();
|
this.setPing();
|
||||||
} else if (Packet.ERROR.equals(packet.type)) {
|
} else if (Packet.ERROR.equals(packet.type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user