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