com.neovisionaries.ws.client.WebSocketState Java Examples

The following examples show how to use com.neovisionaries.ws.client.WebSocketState. 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: WebSocketClient.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * clear securing state and reconnect to server
 *
 * @param force if set force true try for reconnect even socket is open.
 *              client do this action because maybe connection lost but client not
 *              detected this actions(android 7.*).
 */

public static void reconnect(boolean force) {

    if ((force || (webSocketClient == null || !webSocketClient.isOpen()))) {
        G.handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (retryConnectionAllowing(latestConnectionTryTiming) && connectionState != WebSocketState.CONNECTING && (connectionState != WebSocketState.OPEN || (HelperTimeOut.timeoutChecking(0, latestConnectionOpenTime, Config.CONNECTION_OPEN_TIME_OUT)))) {
                    if (reconnectQueueLimitation > 0) {
                        reconnectQueueLimitation--;
                    }

                    //if (allowForReconnecting) { // i checked this step, due to the other changes this clause not need
                    //    allowForReconnecting = false;
                    HelperConnectionState.connectionState(ConnectionState.CONNECTING);
                    if (G.allowForConnect) {
                        latestConnectionTryTiming = System.currentTimeMillis();
                        waitingForReconnecting = false;
                        resetWebsocketInfo();
                        WebSocketClient.getInstance();
                        checkSocketConnection();
                    }
                    //}
                } else {
                    if (reconnectQueueLimitation < Config.TRY_CONNECTION_COUNT) {
                        reconnectQueueLimitation++;
                        allowForReconnecting = true;
                        waitingForReconnecting = false;
                        reconnect(false);
                    } else {
                        reconnectQueueLimitation--;
                    }
                }
            }
        }, Config.REPEAT_CONNECTION_CHECKING);
    }
}
 
Example #2
Source File: CustomWebSocketListener.java    From WebRTCapp with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(WebSocket websocket, WebSocketState newState) throws Exception {
    Log.i(TAG, "State changed: " + newState.name());
}
 
Example #3
Source File: WebSocketListener.java    From FlareBot with MIT License 4 votes vote down vote up
@Override
public void onStateChanged(WebSocket webSocket, WebSocketState webSocketState) throws Exception {
}
 
Example #4
Source File: WebSocketLogger.java    From Javacord with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(WebSocket websocket, WebSocketState newState) {
    logger.trace("onStateChanged: newState='{}'", newState);
}
 
Example #5
Source File: SystemStatusService.java    From AirMapSDK-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(WebSocket websocket, WebSocketState newState) throws Exception {
    super.onStateChanged(websocket, newState);
    Timber.i("New Websocket State: %s", newState.name());
}
 
Example #6
Source File: Socket.java    From socketcluster-client-java with Apache License 2.0 4 votes vote down vote up
public Boolean isconnected() {
    return ws != null && ws.getState() == WebSocketState.OPEN;
}
 
Example #7
Source File: WebSocketLogger.java    From Javacord with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(WebSocket websocket, WebSocketState newState) {
    logger.trace("onStateChanged: newState='{}'", newState);
}
 
Example #8
Source File: Socket.java    From socketcluster-client-java with Apache License 2.0 2 votes vote down vote up
/**
 * States can be
 * CLOSED
 * CLOSING
 * CONNECTING
 * CREATED
 * OPEN
 */

public WebSocketState getCurrentState() {
    return ws != null ? ws.getState() : null;
}