/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (}{@link WebSocketCloseCode#NORMAL}{@code , null)}. * </p> * * @return * {@code this} object. */ public WebSocket disconnect() { return disconnect(WebSocketCloseCode.NORMAL, null); }
/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (closeCode, null)}. * </p> * * @param closeCode * The close code embedded in a <a href= * "https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a> * which this WebSocket client will send to the server. * * @return * {@code this} object. * * @since 1.5 */ public WebSocket disconnect(int closeCode) { return disconnect(closeCode, null); }
/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (}{@link WebSocketCloseCode#NORMAL}{@code , reason)}. * </p> * * @param reason * The reason embedded in a <a href= * "https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a> * which this WebSocket client will send to the server. Note that * the length of the bytes which represents the given reason must * not exceed 125. In other words, {@code (reason.}{@link * String#getBytes(String) getBytes}{@code ("UTF-8").length <= 125)} * must be true. * * @return * {@code this} object. * * @since 1.5 */ public WebSocket disconnect(String reason) { return disconnect(WebSocketCloseCode.NORMAL, reason); }
return disconnect(closeCode, reason, DEFAULT_CLOSE_DELAY);
import com.neovisionaries.ws.client.*; public class HelloWSS { public static void main(String[] args) throws Exception { // Connect to "wss://echo.websocket.org" and send "Hello." to it. // When a response from the WebSocket server is received, the // WebSocket connection is closed. new WebSocketFactory() .createSocket("wss://echo.websocket.org") .addListener(new WebSocketAdapter() { @Override public void onTextMessage(WebSocket ws, String message) { // Received a response. Print the received message. System.out.println(message); // Close the WebSocket connection. ws.disconnect(); } }) .connect() .sendText("Hello."); } }
public void disconnect() { ws.disconnect(); strategy = null; }
/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (}{@link WebSocketCloseCode#NORMAL}{@code , null)}. * </p> * * @return * {@code this} object. */ public WebSocket disconnect() { return disconnect(WebSocketCloseCode.NORMAL, null); }
/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (closeCode, null)}. * </p> * * @param closeCode * The close code embedded in a <a href= * "https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a> * which this WebSocket client will send to the server. * * @return * {@code this} object. * * @since 1.5 */ public WebSocket disconnect(int closeCode) { return disconnect(closeCode, null); }
/** * Disconnect the WebSocket. * * <p> * This method is an alias of {@link #disconnect(int, String) * disconnect}{@code (}{@link WebSocketCloseCode#NORMAL}{@code , reason)}. * </p> * * @param reason * The reason embedded in a <a href= * "https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a> * which this WebSocket client will send to the server. Note that * the length of the bytes which represents the given reason must * not exceed 125. In other words, {@code (reason.}{@link * String#getBytes(String) getBytes}{@code ("UTF-8").length <= 125)} * must be true. * * @return * {@code this} object. * * @since 1.5 */ public WebSocket disconnect(String reason) { return disconnect(WebSocketCloseCode.NORMAL, reason); }
return disconnect(closeCode, reason, DEFAULT_CLOSE_DELAY);
/** Disconnect the client from the server */ public void disconnect() { mConnected = false; mListeners.clear(); mSessionID = null; if (mWebSocket != null) { try { mWebSocket.disconnect(); } catch (Exception e) { mCallbackProxy.onException(e); } } else { throw new IllegalStateException("You must have called the 'connect' method before you can disconnect again"); } }
public void stop() { stopPingTimer(); if(mConnection != null && mConnection.isOpen()) { mConnection.disconnect(); } }
/** * Disconnecting from WebSocket */ @Synchronized public void disconnect() { if (connectionState.equals(TMIConnectionState.CONNECTED)) { connectionState = TMIConnectionState.DISCONNECTING; } connectionState = TMIConnectionState.DISCONNECTED; // CleanUp this.webSocket.clearListeners(); this.webSocket.disconnect(); this.webSocket = null; }
/** * Disconnecting from IRC-WS */ @Synchronized public void disconnect() { if (connectionState.equals(TMIConnectionState.CONNECTED)) { connectionState = TMIConnectionState.DISCONNECTING; sendCommand("QUIT"); // safe disconnect } connectionState = TMIConnectionState.DISCONNECTED; // CleanUp this.webSocket.clearListeners(); this.webSocket.disconnect(); this.webSocket = null; }