org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose Java Examples

The following examples show how to use org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceSocket.java    From JMeter-WebSocketSampler with Apache License 2.0 6 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    if (statusCode != 1000) {
        log.error("Disconnect " + statusCode + ": " + reason);
        logMessage.append(" - WebSocket conection closed unexpectedly by the server: [").append(statusCode).append("] ").append(reason).append("\n");
        error = statusCode;
    } else {
        logMessage.append(" - WebSocket conection has been successfully closed by the server").append("\n");
        log.debug("Disconnect " + statusCode + ": " + reason);
    }
    
    //Notify connection opening and closing latches of the closed connection
    openLatch.countDown();
    closeLatch.countDown();
    connected = false;
}
 
Example #2
Source File: JettyWebSocketHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@OnWebSocketClose
public void onWebSocketClose(int statusCode, String reason) {
	CloseStatus closeStatus = new CloseStatus(statusCode, reason);
	try {
		this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus);
	}
	catch (Throwable ex) {
		if (logger.isWarnEnabled()) {
			logger.warn("Unhandled exception after connection closed for " + this, ex);
		}
	}
}
 
Example #3
Source File: EgressInteractiveHandler.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose    
public void onWebSocketClose(Session session, int statusCode, String reason) {
  try {
    this.processor.getPipe().close();
  } catch (IOException ioe) {        
  }
}
 
Example #4
Source File: AutoConnectSocket.java    From ariADDna with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    System.out.printf("Connection closed: %d - %s%n", statusCode, reason);
    this.session = null;
    this.closeLatch.countDown(); // trigger latch
    listener.onClose(statusCode, reason);
}
 
Example #5
Source File: CoinbaseSocket.java    From cloud-bigtable-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Handler to cleanup on close.
 * @param statusCode Status code of closing
 * @param reason Reason the socket is being closed
 */
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  LOG.info("Connection closed: {} - %s{}", statusCode, reason);
  try {
    this.start();
  } catch (IOException e) {
    LOG.error("Failure to restart web socket {}", e.getMessage());
  }
}
 
Example #6
Source File: JettyWebSocketHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onWebSocketClose(int statusCode, String reason) {
	CloseStatus closeStatus = new CloseStatus(statusCode, reason);
	try {
		this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus);
	}
	catch (Throwable ex) {
		if (logger.isErrorEnabled()) {
			logger.error("Unhandled error for " + this.wsSession, ex);
		}
	}
}
 
Example #7
Source File: WebSocketProvider.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose @SuppressWarnings("unused")
public void onWebSocketClose(final int statusCode, final String reason)
{
    if (_protocolEngine != null)
    {
        _protocolEngine.closed();
    }
    _activeConnections.remove(_connectionWrapper);
    _idleTimeoutChecker.wakeup();
    _netInputBuffer.dispose();
}
 
Example #8
Source File: SonyAudioClientSocket.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    session = null;
    connected = false;
    logger.debug("Closing a WebSocket due to {}", reason);
    scheduler.submit(() -> {
        try {
            eventHandler.onConnectionClosed();
        } catch (Exception e) {
            logger.error("Error handling onConnectionClosed()", e);
        }
    });
}
 
Example #9
Source File: WebSocketChannelImpl.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int closeCode, String closeReason) {
  LOG.info(
      "Websocket[" + connectionId + "] disconnected (" + closeCode + " - " + closeReason + ")");
  synchronized (this) {
    if (closeCode == 1001) {
      // the client browser has closed the connection, we can clean up this
      // connection.
      cancel();
    }

    session = null;
  }
}
 
Example #10
Source File: WebSocketConnection.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
	if (statusCode != StatusCode.NORMAL)
		log.error("Disconnect " + statusCode + ": " + reason);
	else
		log.debug("Disconnect " + statusCode + ": " + reason);
    openLatch.countDown();
    closeLatch.countDown();
    connected = false;
}
 
Example #11
Source File: JettySocket.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    logger.error("Connection Closed: code: " + statusCode + " reason: " + reason);
    shouldRun = false;
    this.session = null;
    connected = false;
    if( disconnectListener != null ) {
        disconnectListener.socketDisconnectDetected();
    }
}
 
Example #12
Source File: JettySocket.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    logger.error("Connection Closed: code: " + statusCode + " reason: " + reason);
    shouldRun = false;
    this.session = null;
    connected = false;
    if( disconnectListener != null ) {
        disconnectListener.socketDisconnectDetected();
    }
}
 
Example #13
Source File: SimpleWebSocket.java    From java-11-examples with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    LOG.info("Connection closed: {} - {}", statusCode, reason);
    this.session = null;
    this.closeLatch.countDown(); // trigger latch
    this.sessionListener.onSessionClose();
}
 
Example #14
Source File: WebSocketTargetSocket.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  if (statusCode != StatusCode.NORMAL) {
    LOG.error(Utils.format("WebSocket Connection closed: {} - {}", statusCode, reason));
  }
  this.closeLatch.countDown();
}
 
Example #15
Source File: WebSocketClientSource.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  if (statusCode != StatusCode.NORMAL) {
    LOG.error(Utils.format("WebSocket Connection closed: {} - {}", statusCode, reason));
    try {
      connectToWebSocket();
    } catch (Exception e) {
      LOG.error(Errors.WEB_SOCKET_01.getMessage(), e.toString(), e);
    }
  }
}
 
Example #16
Source File: JettyWebSocketHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@OnWebSocketClose
public void onWebSocketClose(int statusCode, String reason) {
	CloseStatus closeStatus = new CloseStatus(statusCode, reason);
	try {
		this.webSocketHandler.afterConnectionClosed(this.wsSession, closeStatus);
	}
	catch (Throwable ex) {
		if (logger.isWarnEnabled()) {
			logger.warn("Unhandled exception after connection closed for " + this, ex);
		}
	}
}
 
Example #17
Source File: WebSocketChannelImpl.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int closeCode, String closeReason) {
  LOG.fine("websocket disconnected (" + closeCode + " - " + closeReason + "): " + this);
  synchronized (this) {
    session = null;
  }
}
 
Example #18
Source File: LogWebSocketHandler.java    From android-uiconductor with Apache License 2.0 5 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  try {
    if (inputStream != null) {
      inputStream.close();
    }
  } catch (Exception e) {
    logger.warning(e.getMessage());
  }
  if (process != null) {
    process.destroy();
  }
}
 
Example #19
Source File: ConsoleProxyNoVNCHandler.java    From cloudstack with Apache License 2.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(Session session, int statusCode, String reason) throws IOException, InterruptedException {
    ConsoleProxy.removeViewer(viewer);
}
 
Example #20
Source File: ConsoleLogSocket.java    From gocd with Apache License 2.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int status, String reason) {
    socketHealthService.deregister(this);
}
 
Example #21
Source File: WebSocketImpl.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
	close();
}
 
Example #22
Source File: ChatWebSocket.java    From stepic_java_webserver with MIT License 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    chatService.remove(this);
}
 
Example #23
Source File: VisWebSocket.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose (Session peer, int in, String cause) {
    peers.remove(peer);
    System.out.println("onClose: cause="+cause);
    WebSocketDB.getInstance().unRegisterSocket(this);
}
 
Example #24
Source File: Peer.java    From nextrtc-signaling-server with MIT License 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int status, String reason) {
    session = null;
    log.add(create().content(reason).build());
}
 
Example #25
Source File: SimpleEchoSocket.java    From java_rosbridge with GNU Lesser General Public License v3.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
	System.out.printf("Connection closed: %d - %s%n", statusCode, reason);
	this.session = null;
	this.closeLatch.countDown();
}
 
Example #26
Source File: BuckSocket.java    From buck with Apache License 2.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  connected.set(false);
  this.session = null;
  eventsHandler.onDisconnect();
}
 
Example #27
Source File: RosBridge.java    From java_rosbridge with GNU Lesser General Public License v3.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
	System.out.printf("Connection closed: %d - %s%n", statusCode, reason);
	this.session = null;
	this.closeLatch.countDown();
}
 
Example #28
Source File: WebSocketRunnerMock.java    From codenjoy with GNU General Public License v3.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int closeCode, String message) {
    System.out.println("client closed!");
    closed = true;
}
 
Example #29
Source File: ChatWebSocket.java    From tp_java_2015_02 with MIT License 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
    users.remove(this);
    logger.info("onClose");
}
 
Example #30
Source File: SimpleEchoSocket.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
  System.out.printf("Connection closed: %d - %s%n",statusCode,reason);
  this.closeLatch.countDown();
}