compatible with socket.io-client 1.1.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.github.nkzawa.hasbinarydata;
|
||||
package com.github.nkzawa.hasbinary;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -6,15 +6,15 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class HasBinaryData {
|
||||
public class HasBinary {
|
||||
|
||||
private HasBinaryData() {}
|
||||
private HasBinary() {}
|
||||
|
||||
public static boolean hasBinary(Object data) {
|
||||
return recursiveCheckForBinary(data);
|
||||
return _hasBinary(data);
|
||||
}
|
||||
|
||||
private static boolean recursiveCheckForBinary(Object obj) {
|
||||
private static boolean _hasBinary(Object obj) {
|
||||
if (obj == null) return false;
|
||||
|
||||
if (obj instanceof byte[]) {
|
||||
@@ -31,7 +31,7 @@ public class HasBinaryData {
|
||||
} catch (JSONException e) {
|
||||
return false;
|
||||
}
|
||||
if (recursiveCheckForBinary(v)) {
|
||||
if (_hasBinary(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class HasBinaryData {
|
||||
} catch (JSONException e) {
|
||||
return false;
|
||||
}
|
||||
if (recursiveCheckForBinary(v)) {
|
||||
if (_hasBinary(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,8 @@ public class Manager extends Emitter {
|
||||
}
|
||||
|
||||
private void maybeReconnectOnOpen() {
|
||||
if (!this.openReconnect && !this.reconnecting && this._reconnection) {
|
||||
// Only try to reconnect if it's the first time we're connecting
|
||||
if (!this.openReconnect && !this.reconnecting && this._reconnection && this.attempts == 0) {
|
||||
this.openReconnect = true;
|
||||
this.reconnect();
|
||||
}
|
||||
@@ -425,7 +426,7 @@ public class Manager extends Emitter {
|
||||
while ((sub = this.subs.poll()) != null) sub.destroy();
|
||||
}
|
||||
|
||||
private void close() {
|
||||
/*package*/ void close() {
|
||||
this.skipReconnect = true;
|
||||
this.engine.close();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.nkzawa.socketio.client;
|
||||
|
||||
import com.github.nkzawa.emitter.Emitter;
|
||||
import com.github.nkzawa.hasbinarydata.HasBinaryData;
|
||||
import com.github.nkzawa.hasbinary.HasBinary;
|
||||
import com.github.nkzawa.socketio.parser.Packet;
|
||||
import com.github.nkzawa.socketio.parser.Parser;
|
||||
import com.github.nkzawa.thread.EventThread;
|
||||
@@ -173,7 +173,7 @@ public class Socket extends Emitter {
|
||||
jsonArgs.put(arg);
|
||||
}
|
||||
int parserType = Parser.EVENT;
|
||||
if (HasBinaryData.hasBinary(jsonArgs)) { parserType = Parser.BINARY_EVENT; }
|
||||
if (HasBinary.hasBinary(jsonArgs)) { parserType = Parser.BINARY_EVENT; }
|
||||
Packet<JSONArray> packet = new Packet<JSONArray>(parserType, jsonArgs);
|
||||
|
||||
if (_args.get(_args.size() - 1) instanceof Ack) {
|
||||
@@ -324,7 +324,7 @@ public class Socket extends Emitter {
|
||||
sent[0] = true;
|
||||
logger.fine(String.format("sending ack %s", args.length != 0 ? args : null));
|
||||
|
||||
int type = HasBinaryData.hasBinary(args) ? Parser.BINARY_ACK : Parser.ACK;
|
||||
int type = HasBinary.hasBinary(args) ? Parser.BINARY_ACK : Parser.ACK;
|
||||
Packet<JSONArray> packet = new Packet<JSONArray>(type, new JSONArray(Arrays.asList(args)));
|
||||
packet.id = id;
|
||||
self.packet(packet);
|
||||
|
||||
Reference in New Issue
Block a user