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