improve tests
This commit is contained in:
@@ -3,6 +3,7 @@ package io.socket.client.executions;
|
|||||||
import io.socket.emitter.Emitter;
|
import io.socket.emitter.Emitter;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
@@ -11,6 +12,11 @@ public class Connection {
|
|||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
IO.Options options = new IO.Options();
|
IO.Options options = new IO.Options();
|
||||||
options.forceNew = true;
|
options.forceNew = true;
|
||||||
|
|
||||||
|
final OkHttpClient client = new OkHttpClient();
|
||||||
|
options.webSocketFactory = client;
|
||||||
|
options.callFactory = client;
|
||||||
|
|
||||||
final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
|
final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -19,6 +25,13 @@ public class Connection {
|
|||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
socket.io().on(io.socket.engineio.client.Socket.EVENT_CLOSE, new Emitter.Listener() {
|
||||||
|
@Override
|
||||||
|
public void call(Object... args) {
|
||||||
|
System.out.println("engine close");
|
||||||
|
client.dispatcher().executorService().shutdown();
|
||||||
|
}
|
||||||
|
});
|
||||||
socket.open();
|
socket.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.socket.client.executions;
|
|||||||
import io.socket.emitter.Emitter;
|
import io.socket.emitter.Emitter;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
@@ -14,6 +15,11 @@ public class ConnectionFailure {
|
|||||||
IO.Options options = new IO.Options();
|
IO.Options options = new IO.Options();
|
||||||
options.forceNew = true;
|
options.forceNew = true;
|
||||||
options.reconnection = false;
|
options.reconnection = false;
|
||||||
|
|
||||||
|
final OkHttpClient client = new OkHttpClient();
|
||||||
|
options.webSocketFactory = client;
|
||||||
|
options.callFactory = client;
|
||||||
|
|
||||||
final Socket socket = IO.socket("http://localhost:" + port, options);
|
final Socket socket = IO.socket("http://localhost:" + port, options);
|
||||||
socket.on(Socket.EVENT_CONNECT_TIMEOUT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT_TIMEOUT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -24,6 +30,7 @@ public class ConnectionFailure {
|
|||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
System.out.println("connect error");
|
System.out.println("connect error");
|
||||||
|
client.dispatcher().executorService().shutdown();
|
||||||
}
|
}
|
||||||
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
|
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.socket.client.executions;
|
|||||||
import io.socket.emitter.Emitter;
|
import io.socket.emitter.Emitter;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
@@ -11,6 +12,11 @@ public class ImmediateClose {
|
|||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
IO.Options options = new IO.Options();
|
IO.Options options = new IO.Options();
|
||||||
options.forceNew = true;
|
options.forceNew = true;
|
||||||
|
|
||||||
|
final OkHttpClient client = new OkHttpClient();
|
||||||
|
options.webSocketFactory = client;
|
||||||
|
options.callFactory = client;
|
||||||
|
|
||||||
final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
|
final Socket socket = IO.socket("http://localhost:" + System.getenv("PORT"), options);
|
||||||
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -23,6 +29,13 @@ public class ImmediateClose {
|
|||||||
System.out.println("disconnect");
|
System.out.println("disconnect");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
socket.io().on(io.socket.engineio.client.Socket.EVENT_CLOSE, new Emitter.Listener() {
|
||||||
|
@Override
|
||||||
|
public void call(Object... args) {
|
||||||
|
System.out.println("engine close");
|
||||||
|
client.dispatcher().executorService().shutdown();
|
||||||
|
}
|
||||||
|
});
|
||||||
socket.connect();
|
socket.connect();
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user