File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
src/test/java/io/socket/client/executions Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 33import io .socket .emitter .Emitter ;
44import io .socket .client .IO ;
55import io .socket .client .Socket ;
6+ import okhttp3 .OkHttpClient ;
67
78import java .net .URISyntaxException ;
89
@@ -11,6 +12,11 @@ public class Connection {
1112 public static void main (String [] args ) throws URISyntaxException {
1213 IO .Options options = new IO .Options ();
1314 options .forceNew = true ;
15+
16+ final OkHttpClient client = new OkHttpClient ();
17+ options .webSocketFactory = client ;
18+ options .callFactory = client ;
19+
1420 final Socket socket = IO .socket ("http://localhost:" + System .getenv ("PORT" ), options );
1521 socket .on (Socket .EVENT_CONNECT , new Emitter .Listener () {
1622 @ Override
@@ -19,6 +25,13 @@ public void call(Object... args) {
1925 socket .close ();
2026 }
2127 });
28+ socket .io ().on (io .socket .engineio .client .Socket .EVENT_CLOSE , new Emitter .Listener () {
29+ @ Override
30+ public void call (Object ... args ) {
31+ System .out .println ("engine close" );
32+ client .dispatcher ().executorService ().shutdown ();
33+ }
34+ });
2235 socket .open ();
2336 }
2437}
Original file line number Diff line number Diff line change 33import io .socket .emitter .Emitter ;
44import io .socket .client .IO ;
55import io .socket .client .Socket ;
6+ import okhttp3 .OkHttpClient ;
67
78import java .net .URISyntaxException ;
89
@@ -14,6 +15,11 @@ public static void main(String[] args) throws URISyntaxException {
1415 IO .Options options = new IO .Options ();
1516 options .forceNew = true ;
1617 options .reconnection = false ;
18+
19+ final OkHttpClient client = new OkHttpClient ();
20+ options .webSocketFactory = client ;
21+ options .callFactory = client ;
22+
1723 final Socket socket = IO .socket ("http://localhost:" + port , options );
1824 socket .on (Socket .EVENT_CONNECT_TIMEOUT , new Emitter .Listener () {
1925 @ Override
@@ -24,6 +30,7 @@ public void call(Object... args) {
2430 @ Override
2531 public void call (Object ... args ) {
2632 System .out .println ("connect error" );
33+ client .dispatcher ().executorService ().shutdown ();
2734 }
2835 }).on (Socket .EVENT_DISCONNECT , new Emitter .Listener () {
2936 @ Override
Original file line number Diff line number Diff line change 33import io .socket .emitter .Emitter ;
44import io .socket .client .IO ;
55import io .socket .client .Socket ;
6+ import okhttp3 .OkHttpClient ;
67
78import java .net .URISyntaxException ;
89
@@ -11,6 +12,11 @@ public class ImmediateClose {
1112 public static void main (String [] args ) throws URISyntaxException {
1213 IO .Options options = new IO .Options ();
1314 options .forceNew = true ;
15+
16+ final OkHttpClient client = new OkHttpClient ();
17+ options .webSocketFactory = client ;
18+ options .callFactory = client ;
19+
1420 final Socket socket = IO .socket ("http://localhost:" + System .getenv ("PORT" ), options );
1521 socket .on (Socket .EVENT_CONNECT , new Emitter .Listener () {
1622 @ Override
@@ -23,6 +29,13 @@ public void call(Object... args) {
2329 System .out .println ("disconnect" );
2430 }
2531 });
32+ socket .io ().on (io .socket .engineio .client .Socket .EVENT_CLOSE , new Emitter .Listener () {
33+ @ Override
34+ public void call (Object ... args ) {
35+ System .out .println ("engine close" );
36+ client .dispatcher ().executorService ().shutdown ();
37+ }
38+ });
2639 socket .connect ();
2740 socket .disconnect ();
2841 }
You can’t perform that action at this time.
0 commit comments