add connected method

This commit is contained in:
Naoyuki Kanezawa
2014-11-04 01:16:28 +09:00
parent 1aa6e4a907
commit 575fecc2d8

View File

@@ -68,8 +68,7 @@ public class Socket extends Emitter {
put(EVENT_RECONNECTING, 1); put(EVENT_RECONNECTING, 1);
}}; }};
private boolean connected; private volatile boolean connected;
private boolean disconnected = true;
private int ids; private int ids;
private String nsp; private String nsp;
private Manager io; private Manager io;
@@ -258,7 +257,6 @@ public class Socket extends Emitter {
private void onclose(String reason) { private void onclose(String reason) {
logger.fine(String.format("close (%s)", reason)); logger.fine(String.format("close (%s)", reason));
this.connected = false; this.connected = false;
this.disconnected = true;
this.emit(EVENT_DISCONNECT, reason); this.emit(EVENT_DISCONNECT, reason);
} }
@@ -344,7 +342,6 @@ public class Socket extends Emitter {
private void onconnect() { private void onconnect() {
this.connected = true; this.connected = true;
this.disconnected = false;
this.emit(EVENT_CONNECT); this.emit(EVENT_CONNECT);
this.emitBuffered(); this.emitBuffered();
} }
@@ -419,6 +416,10 @@ public class Socket extends Emitter {
return io; return io;
} }
public boolean connected() {
return connected;
}
private static Object[] toArray(JSONArray array) { private static Object[] toArray(JSONArray array) {
int length = array.length(); int length = array.length();
Object[] data = new Object[length]; Object[] data = new Object[length];