File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
main/java/com/crossoverjie/cim/client/sdk/impl
test/java/com/crossoverjie/cim/client/sdk Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ public void close() {
219
219
channel .close ();
220
220
channel = null ;
221
221
}
222
+ super .setState (ClientState .State .Closed );
222
223
this .routeManager .offLine (this .getAuth ().getUserId ());
223
224
}
224
225
Original file line number Diff line number Diff line change @@ -365,4 +365,33 @@ public void offLineAndOnline() throws Exception {
365
365
super .stopSingle ();
366
366
}
367
367
368
+ @ Test
369
+ public void testClose () throws Exception {
370
+ super .starSingleServer ();
371
+ super .startRoute ();
372
+ String routeUrl = "http://localhost:8083" ;
373
+ String cj = "crossoverJie" ;
374
+ Long id = super .registerAccount (cj );
375
+ var auth1 = ClientConfigurationData .Auth .builder ()
376
+ .userId (id )
377
+ .userName (cj )
378
+ .build ();
379
+
380
+ Client client1 = Client .builder ()
381
+ .auth (auth1 )
382
+ .routeUrl (routeUrl )
383
+ .build ();
384
+ TimeUnit .SECONDS .sleep (3 );
385
+ ClientState .State state = client1 .getState ();
386
+ Awaitility .await ().atMost (10 , TimeUnit .SECONDS )
387
+ .untilAsserted (() -> Assertions .assertEquals (ClientState .State .Ready , state ));
388
+ Optional <CIMServerResVO > serverInfo = client1 .getServerInfo ();
389
+ Assertions .assertTrue (serverInfo .isPresent ());
390
+ System .out .println ("client1 serverInfo = " + serverInfo .get ());
391
+
392
+ client1 .close ();
393
+ ClientState .State state1 = client1 .getState ();
394
+ Assertions .assertEquals (ClientState .State .Closed , state1 );
395
+ }
396
+
368
397
}
You can’t perform that action at this time.
0 commit comments