fix reconnection option

This commit is contained in:
Naoyuki Kanezawa
2013-08-04 14:59:44 +09:00
parent 9bb5d366ce
commit 2a7841b587
3 changed files with 14 additions and 17 deletions

View File

@@ -80,7 +80,7 @@ public class IO {
*/
public boolean multiplex = true;
public boolean reconnection;
public boolean reconnection = true;
public int reconnectionAttempts;
public long reconnectionDelay;
public long reconnectionDelayMax;

View File

@@ -321,7 +321,7 @@ public class Manager extends Emitter {
private void onclose() {
this.cleanup();
this.readyState = ReadyState.CLOSED;
if (!this.skipReconnect) {
if (this._reconnection && !this.skipReconnect) {
this.reconnect();
}
}

View File

@@ -87,9 +87,7 @@ public class ServerConnectionTest {
public void openAndClose() throws URISyntaxException, InterruptedException {
final BlockingQueue<String> events = new LinkedBlockingQueue<String>();
IO.Options opts = new IO.Options();
opts.forceNew = true;
socket = IO.socket(uri(), opts);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -114,9 +112,7 @@ public class ServerConnectionTest {
public void message() throws URISyntaxException, InterruptedException {
final BlockingQueue<Object[]> events = new LinkedBlockingQueue<Object[]>();
IO.Options opts = new IO.Options();
opts.forceNew = true;
socket = IO.socket(uri(), opts);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -145,9 +141,7 @@ public class ServerConnectionTest {
final JsonObject obj = new JsonObject();
obj.addProperty("foo", 1);
IO.Options opts = new IO.Options();
opts.forceNew = true;
socket = IO.socket(uri(), opts);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -174,9 +168,7 @@ public class ServerConnectionTest {
final JsonObject obj = new JsonObject();
obj.addProperty("foo", 1);
IO.Options opts = new IO.Options();
opts.forceNew = true;
socket = IO.socket(uri(), opts);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -200,9 +192,7 @@ public class ServerConnectionTest {
public void ackWithoutArgs() throws URISyntaxException, InterruptedException {
final BlockingQueue<Object[]> events = new LinkedBlockingQueue<Object[]>();
IO.Options opts = new IO.Options();
opts.forceNew = true;
socket = IO.socket(uri(), opts);
socket = client();
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
@@ -221,6 +211,13 @@ public class ServerConnectionTest {
socket.disconnect();
}
private Socket client() throws URISyntaxException {
IO.Options opts = new IO.Options();
opts.forceNew = true;
opts.reconnection = false;
return IO.socket(uri(), opts);
}
private String uri() {
return "http://localhost:" + PORT + nsp();
}