@SuppressWarnings("incomplete-switch") @Override public void onConnectionStateChange(ConnectionState state) { switch (state) { case CLOSED: IOState ioState = this.connection.getIOState(); CloseInfo close = ioState.getCloseInfo(); // confirmed close of local endpoint notifyClose(close.getStatusCode(), close.getReason()); // notify session listeners for (SessionListener listener : sessionListeners) { try { if (LOG.isDebugEnabled()) LOG.debug("{}.onSessionClosed()", listener.getClass().getSimpleName()); listener.onSessionClosed(this); } catch (Throwable t) { LOG.ignore(t); } } break; case CONNECTED: // notify session listeners for (SessionListener listener : sessionListeners) { try { if (LOG.isDebugEnabled()) LOG.debug("{}.onSessionOpen()", listener.getClass().getSimpleName()); listener.onSessionOpened(this); } catch (Throwable t) { LOG.ignore(t); } } break; } }
/** Harsh disconnect */ @Override public void disconnect() { connection.disconnect(); // notify of harsh disconnect notifyClose(StatusCode.NO_CLOSE, "Harsh disconnect"); }