Skip to content

Commit 48420a6

Browse files
committed
improve manager disconnection and cleanup
1 parent 1fd635b commit 48420a6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/io/socket/client/Manager.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,22 @@ private void cleanup() {
490490
On.Handle sub;
491491
while ((sub = this.subs.poll()) != null) sub.destroy();
492492

493+
this.packetBuffer.clear();
494+
this.encoding = false;
493495
this.lastPing = null;
496+
497+
this.decoder.destroy();
494498
}
495499

496500
/*package*/ void close() {
501+
logger.fine("disconnect");
502+
this.skipReconnect = true;
503+
this.reconnecting = false;
497504
if (this.readyState != ReadyState.OPEN) {
505+
// `onclose` will not fire because
506+
// an open event never happened
498507
this.cleanup();
499508
}
500-
this.skipReconnect = true;
501-
this.reconnecting = false;
502509
this.backoff.reset();
503510
this.readyState = ReadyState.CLOSED;
504511
if (this.engine != null) {
@@ -507,7 +514,7 @@ private void cleanup() {
507514
}
508515

509516
private void onclose(String reason) {
510-
logger.fine("close");
517+
logger.fine("onclose");
511518
this.cleanup();
512519
this.backoff.reset();
513520
this.readyState = ReadyState.CLOSED;

0 commit comments

Comments
 (0)