void handleSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeIncompleteSession(error, closeReason, reconnectAllowed); }
@Override public void onCompletion(IWampConnectionFuture<Void> future) { // Is called once the disconnect from the previous transport has happened if (nrReconnectAttempts == 0) { DisconnectedState newState = new DisconnectedState(stateController, null); stateController.setState(newState); } else { WaitingForReconnectState newState = new WaitingForReconnectState(stateController, nrReconnectAttempts); stateController.setState(newState); } }
void onSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeSession(error, closeReason, reconnectAllowed); }
@Override public void call() { if (stateController.currentState() != WaitingForReconnectState.this) return; // Reconnect now ConnectingState newState = new ConnectingState(stateController, nrReconnectAttempts); stateController.setState(newState); } }, stateController.clientConfig().reconnectInterval(), TimeUnit.MILLISECONDS);
@Override public void run() { if (!(currentState instanceof InitialState)) return; // Try to connect afterwards // This guarantees that the external state will always // switch to connecting, even when the attempt immediately // fails int nrConnects = clientConfig.totalNrReconnects(); if (nrConnects == 0) nrConnects = 1; ConnectingState newState = new ConnectingState(StateController.this, nrConnects); setState(newState); } });
@Override public void initClose() { DisconnectedState nextState = new DisconnectedState(stateController, null); stateController.setState(nextState); } }
/** * Is called if the underlying connection was closed from the remote side. * Won't be called if the user issues the close, since the client will then move * to the {@link WaitingForDisconnectState} directly. * @param closeReason An optional reason why the connection closed. */ void onConnectionClosed(Throwable closeReason) { if (currentState instanceof SessionEstablishedState) ((SessionEstablishedState)currentState).onConnectionClosed(closeReason); else if (currentState instanceof HandshakingState) ((HandshakingState)currentState).onConnectionClosed(closeReason); }
/** * Is called when the underlying connection received a message from the remote side. * @param message The received message */ void onMessage(WampMessage message) { if (currentState instanceof SessionEstablishedState) ((SessionEstablishedState)currentState).onMessage(message); else if (currentState instanceof HandshakingState) ((HandshakingState)currentState).onMessage(message); }
void handleSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeIncompleteSession(error, closeReason, reconnectAllowed); }
void onSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeSession(error, closeReason, reconnectAllowed); }
@Override public void onCompletion(IWampConnectionFuture<Void> future) { // Is called once the disconnect from the previous transport has happened if (nrReconnectAttempts == 0) { DisconnectedState newState = new DisconnectedState(stateController, null); stateController.setState(newState); } else { WaitingForReconnectState newState = new WaitingForReconnectState(stateController, nrReconnectAttempts); stateController.setState(newState); } }
@Override public void call() { if (stateController.currentState() != WaitingForReconnectState.this) return; // Reconnect now ConnectingState newState = new ConnectingState(stateController, nrReconnectAttempts); stateController.setState(newState); } }, stateController.clientConfig().reconnectInterval(), TimeUnit.MILLISECONDS);
@Override public void initClose() { DisconnectedState nextState = new DisconnectedState(stateController, null); stateController.setState(nextState); } }
/** * Is called if the underlying connection was closed from the remote side. * Won't be called if the user issues the close, since the client will then move * to the {@link WaitingForDisconnectState} directly. * @param closeReason An optional reason why the connection closed. */ void onConnectionClosed(Throwable closeReason) { if (currentState instanceof SessionEstablishedState) ((SessionEstablishedState)currentState).onConnectionClosed(closeReason); else if (currentState instanceof HandshakingState) ((HandshakingState)currentState).onConnectionClosed(closeReason); }
/** * Is called when the underlying connection received a message from the remote side. * @param message The received message */ void onMessage(WampMessage message) { if (currentState instanceof SessionEstablishedState) ((SessionEstablishedState)currentState).onMessage(message); else if (currentState instanceof HandshakingState) ((HandshakingState)currentState).onMessage(message); }
void handleSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeIncompleteSession(error, closeReason, reconnectAllowed); }
void onSessionError(ApplicationError error, String closeReason) { boolean reconnectAllowed = !stateController.clientConfig().closeClientOnErrors(); if (!reconnectAllowed) { // Record the error that happened during the session stateController.setCloseError(error); } closeSession(error, closeReason, reconnectAllowed); }
@Override public void onCompletion(IWampConnectionFuture<Void> future) { // Is called once the disconnect from the previous transport has happened if (nrReconnectAttempts == 0) { DisconnectedState newState = new DisconnectedState(stateController, null); stateController.setState(newState); } else { WaitingForReconnectState newState = new WaitingForReconnectState(stateController, nrReconnectAttempts); stateController.setState(newState); } }
@Override public void call() { if (stateController.currentState() != WaitingForReconnectState.this) return; // Reconnect now ConnectingState newState = new ConnectingState(stateController, nrReconnectAttempts); stateController.setState(newState); } }, stateController.clientConfig().reconnectInterval(), TimeUnit.MILLISECONDS);
@Override public void initClose() { DisconnectedState nextState = new DisconnectedState(stateController, null); stateController.setState(nextState); } }