/** * A websocket connection has failed its upgrade handshake, and is now closed. */ public void onFailedUpgrade() { assert (this.state == ConnectionState.CONNECTING); ConnectionState event = null; synchronized (this) { this.state = ConnectionState.CLOSED; cleanClose = false; inputAvailable = false; outputAvailable = false; event = this.state; } notifyStateListeners(event); }
/** * WebSocket has successfully upgraded, but the end-user onOpen call hasn't run yet. * <p> * This is an intermediate state between the RFC's {@link ConnectionState#CONNECTING} and {@link ConnectionState#OPEN} */ public void onConnected() { ConnectionState event = null; synchronized (this) { if (this.state != ConnectionState.CONNECTING) { LOG.debug("Unable to set to connected, not in CONNECTING state: {}",this.state); return; } this.state = ConnectionState.CONNECTED; inputAvailable = false; // cannot read (yet) outputAvailable = true; // write allowed event = this.state; } notifyStateListeners(event); }
public void onDisconnected() { ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.CLOSED) { // already closed return; } CloseInfo close = new CloseInfo(StatusCode.ABNORMAL,"Disconnected"); this.cleanClose = false; this.state = ConnectionState.CLOSED; this.closeInfo = close; this.inputAvailable = false; this.outputAvailable = false; this.closeHandshakeSource = CloseHandshakeSource.ABNORMAL; event = this.state; } notifyStateListeners(event); }
event = this.state; notifyStateListeners(event);
event = this.state; notifyStateListeners(event);
event = this.state; notifyStateListeners(event);
notifyStateListeners(event); if (abnormalEvent != null) notifyStateListeners(abnormalEvent);
/** * A websocket connection has finished its upgrade handshake, and is now open. */ public void onOpened() { if(LOG.isDebugEnabled()) LOG.debug("onOpened()"); ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.OPEN) { // already opened return; } if (this.state != ConnectionState.CONNECTED) { LOG.debug("Unable to open, not in CONNECTED state: {}",this.state); return; } this.state = ConnectionState.OPEN; this.inputAvailable = true; this.outputAvailable = true; event = this.state; } notifyStateListeners(event); }