Merge branch 'master' of github.com:socketio/socket.io-client-java
This commit is contained in:
@@ -8,8 +8,8 @@ public class Backoff {
|
|||||||
private long ms = 100;
|
private long ms = 100;
|
||||||
private long max = 10000;
|
private long max = 10000;
|
||||||
private int factor = 2;
|
private int factor = 2;
|
||||||
private double jitter = 0.0;
|
private double jitter;
|
||||||
private int attempts = 0;
|
private int attempts;
|
||||||
|
|
||||||
public Backoff() {}
|
public Backoff() {}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class Manager extends Emitter {
|
|||||||
/*package*/ static SSLContext defaultSSLContext;
|
/*package*/ static SSLContext defaultSSLContext;
|
||||||
/*package*/ static HostnameVerifier defaultHostnameVerifier;
|
/*package*/ static HostnameVerifier defaultHostnameVerifier;
|
||||||
|
|
||||||
/*package*/ ReadyState readyState = null;
|
/*package*/ ReadyState readyState;
|
||||||
|
|
||||||
private boolean _reconnection;
|
private boolean _reconnection;
|
||||||
private boolean skipReconnect;
|
private boolean skipReconnect;
|
||||||
@@ -180,7 +180,7 @@ public class Manager extends Emitter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long reconnectionDelay() {
|
public final long reconnectionDelay() {
|
||||||
return this._reconnectionDelay;
|
return this._reconnectionDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ public class Manager extends Emitter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double randomizationFactor() {
|
public final double randomizationFactor() {
|
||||||
return this._randomizationFactor;
|
return this._randomizationFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ public class Manager extends Emitter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long reconnectionDelayMax() {
|
public final long reconnectionDelayMax() {
|
||||||
return this._reconnectionDelayMax;
|
return this._reconnectionDelayMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ public class Manager extends Emitter {
|
|||||||
|
|
||||||
/*package*/ void destroy(Socket socket) {
|
/*package*/ void destroy(Socket socket) {
|
||||||
this.connected.remove(socket);
|
this.connected.remove(socket);
|
||||||
if (this.connected.size() > 0) return;
|
if (!this.connected.isEmpty()) return;
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
@@ -447,7 +447,7 @@ public class Manager extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processPacketQueue() {
|
private void processPacketQueue() {
|
||||||
if (this.packetBuffer.size() > 0 && !this.encoding) {
|
if (!this.packetBuffer.isEmpty() && !this.encoding) {
|
||||||
Packet pack = this.packetBuffer.remove(0);
|
Packet pack = this.packetBuffer.remove(0);
|
||||||
this.packet(pack);
|
this.packet(pack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +325,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
if (args.size() == 0) return;
|
if (args.isEmpty()) return;
|
||||||
String event = args.remove(0).toString();
|
String event = args.remove(0).toString();
|
||||||
super.emit(event, args.toArray());
|
super.emit(event, args.toArray());
|
||||||
} else {
|
} else {
|
||||||
@@ -464,9 +465,10 @@ public class Socket extends Emitter {
|
|||||||
try {
|
try {
|
||||||
v = array.get(i);
|
v = array.get(i);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while retrieving data from JSONArray", e);
|
||||||
v = null;
|
v = null;
|
||||||
}
|
}
|
||||||
data[i] = v == JSONObject.NULL ? null : v;
|
data[i] = JSONObject.NULL.equals(v) ? null : v;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,15 @@ package io.socket.hasbinary;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class HasBinary {
|
public class HasBinary {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(HasBinary.class.getName());
|
||||||
|
|
||||||
private HasBinary() {}
|
private HasBinary() {}
|
||||||
|
|
||||||
public static boolean hasBinary(Object data) {
|
public static boolean hasBinary(Object data) {
|
||||||
@@ -29,6 +33,7 @@ public class HasBinary {
|
|||||||
try {
|
try {
|
||||||
v = _obj.isNull(i) ? null : _obj.get(i);
|
v = _obj.isNull(i) ? null : _obj.get(i);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while retrieving data from JSONArray", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_hasBinary(v)) {
|
if (_hasBinary(v)) {
|
||||||
@@ -44,6 +49,7 @@ public class HasBinary {
|
|||||||
try {
|
try {
|
||||||
v = _obj.get(key);
|
v = _obj.get(key);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while retrieving data from JSONObject", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_hasBinary(v)) {
|
if (_hasBinary(v)) {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.json.JSONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Binary {
|
public class Binary {
|
||||||
|
|
||||||
@@ -14,6 +16,7 @@ public class Binary {
|
|||||||
|
|
||||||
private static final String KEY_NUM = "num";
|
private static final String KEY_NUM = "num";
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Binary.class.getName());
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static DeconstructedPacket deconstructPacket(Packet packet) {
|
public static DeconstructedPacket deconstructPacket(Packet packet) {
|
||||||
@@ -37,6 +40,7 @@ public class Binary {
|
|||||||
placeholder.put(KEY_PLACEHOLDER, true);
|
placeholder.put(KEY_PLACEHOLDER, true);
|
||||||
placeholder.put(KEY_NUM, buffers.size());
|
placeholder.put(KEY_NUM, buffers.size());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
buffers.add((byte[])data);
|
buffers.add((byte[])data);
|
||||||
@@ -49,6 +53,7 @@ public class Binary {
|
|||||||
try {
|
try {
|
||||||
newData.put(i, _deconstructPacket(_data.get(i), buffers));
|
newData.put(i, _deconstructPacket(_data.get(i), buffers));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while putting packet data to JSONObject", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,6 +67,7 @@ public class Binary {
|
|||||||
try {
|
try {
|
||||||
newData.put(key, _deconstructPacket(_data.get(key), buffers));
|
newData.put(key, _deconstructPacket(_data.get(key), buffers));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +91,7 @@ public class Binary {
|
|||||||
try {
|
try {
|
||||||
_data.put(i, _reconstructPacket(_data.get(i), buffers));
|
_data.put(i, _reconstructPacket(_data.get(i), buffers));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while putting packet data to JSONObject", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +108,7 @@ public class Binary {
|
|||||||
try {
|
try {
|
||||||
_data.put(key, _reconstructPacket(_data.get(key), buffers));
|
_data.put(key, _reconstructPacket(_data.get(key), buffers));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while putting data to JSONObject", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.json.JSONTokener;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
@@ -227,6 +228,7 @@ public class Parser {
|
|||||||
str.charAt(++i);
|
str.charAt(++i);
|
||||||
p.data = new JSONTokener(str.substring(i)).nextValue();
|
p.data = new JSONTokener(str.substring(i)).nextValue();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
logger.log(Level.WARNING, "An error occured while retrieving data from JSONTokener", e);
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user