File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
src/test/java/io/socket/engineio/client Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public class ExecutionTest extends Connection {
1717
1818 private static final Logger logger = Logger .getLogger (Socket .class .getName ());
1919
20- final static int TIMEOUT = 100 * 1000 ;
20+ final static int TIMEOUT = 30 * 1000 ;
2121
2222 @ Test (timeout = TIMEOUT )
2323 public void execConnection () throws InterruptedException , IOException {
Original file line number Diff line number Diff line change 22
33import io .socket .emitter .Emitter ;
44import io .socket .engineio .client .Socket ;
5+ import okhttp3 .OkHttpClient ;
56
67import java .net .URISyntaxException ;
78
89public class Connection {
910
1011 public static void main (String [] args ) throws URISyntaxException {
11- final Socket socket = new Socket ("http://localhost:" + System .getenv ("PORT" ));
12+ final OkHttpClient client = new OkHttpClient ();
13+ Socket .Options opts = new Socket .Options ();
14+ opts .webSocketFactory = client ;
15+ opts .callFactory = client ;
16+
17+ final Socket socket = new Socket ("http://localhost:" + System .getenv ("PORT" ), opts );
1218 socket .on (Socket .EVENT_OPEN , new Emitter .Listener () {
1319 @ Override
1420 public void call (Object ... args ) {
1521 System .out .println ("open" );
1622 socket .close ();
1723 }
1824 });
25+ socket .on (Socket .EVENT_CLOSE , new Emitter .Listener () {
26+ @ Override
27+ public void call (Object ... args ) {
28+ client .dispatcher ().executorService ().shutdown ();
29+ }
30+ });
1931 socket .open ();
2032 }
2133}
Original file line number Diff line number Diff line change 22
33import io .socket .emitter .Emitter ;
44import io .socket .engineio .client .Socket ;
5+ import okhttp3 .OkHttpClient ;
56
67import java .net .URISyntaxException ;
78
89public class ConnectionFailure {
910
1011 public static void main (String [] args ) throws URISyntaxException {
12+ final OkHttpClient client = new OkHttpClient ();
13+ Socket .Options opts = new Socket .Options ();
14+ opts .webSocketFactory = client ;
15+ opts .callFactory = client ;
16+
1117 int port = Integer .parseInt (System .getenv ("PORT" ));
1218 port ++;
13- final Socket socket = new Socket ("http://localhost:" + port );
19+ final Socket socket = new Socket ("http://localhost:" + port , opts );
1420 socket .on (Socket .EVENT_CLOSE , new Emitter .Listener () {
1521 @ Override
1622 public void call (Object ... args ) {
@@ -20,6 +26,7 @@ public void call(Object... args) {
2026 @ Override
2127 public void call (Object ... args ) {
2228 System .out .println ("error" );
29+ client .dispatcher ().executorService ().shutdown ();
2330 }
2431 });
2532 socket .open ();
Original file line number Diff line number Diff line change 22
33import io .socket .emitter .Emitter ;
44import io .socket .engineio .client .Socket ;
5+ import okhttp3 .OkHttpClient ;
56
67import java .net .URISyntaxException ;
78
89public class ImmediateClose {
910
1011 public static void main (String [] args ) throws URISyntaxException {
11- final Socket socket = new Socket ("http://localhost:" + System .getenv ("PORT" ));
12+ final OkHttpClient client = new OkHttpClient ();
13+ Socket .Options opts = new Socket .Options ();
14+ opts .webSocketFactory = client ;
15+ opts .callFactory = client ;
16+
17+ final Socket socket = new Socket ("http://localhost:" + System .getenv ("PORT" ), opts );
1218 socket .on (Socket .EVENT_OPEN , new Emitter .Listener () {
1319 @ Override
1420 public void call (Object ... args ) {
@@ -18,6 +24,7 @@ public void call(Object... args) {
1824 @ Override
1925 public void call (Object ... args ) {
2026 System .out .println ("close" );
27+ client .dispatcher ().executorService ().shutdown ();
2128 }
2229 });
2330 socket .open ();
You can’t perform that action at this time.
0 commit comments