private void callImpl() { stateController.scheduler().execute(new Runnable() { @Override public void run() {
@Override public void call() { stateController.scheduler().execute(new Runnable() { @Override public void run() {
@Override public void call() { // There are 2 reasons why the scheduler can reject execution: // 1. The scheduler has shut down. // 2. There are too many outstanding tasks on the queue. // We ignore (1) and rethrow (2). If this code throws then // the number of outstanding tasks allowed can be changed via // the system property "io.netty.eventLoop.maxPendingTasks". // Note that UnsupportedOperationException can be thrown // internally depending on how shutdown races. try { callImpl(); } catch (UnsupportedOperationException | RejectedExecutionException e) { if (!stateController.scheduler().isShutdown()) { throw e; } } }
@Override public void connectSucceeded(final IWampConnection connection) { try { stateController.scheduler().execute(new Runnable() { @Override public void run() { if (!isCancelled) { // Our new channel is connected connectionController.setConnection(connection); HandshakingState newState = new HandshakingState(stateController, connectionController, nrConnectAttempts); stateController.setState(newState); } else { // We we're connected but aren't interested in the channel anymore // The client should close // Therefore we close the new channel stateController.setExternalState(new WampClient.DisconnectedState(null)); WaitingForDisconnectState newState = new WaitingForDisconnectState(stateController, nrConnectAttempts); connection.close(false, newState.closePromise()); stateController.setState(newState); } } }); } catch (RejectedExecutionException e) { connection.close(false, IWampConnectionPromise.Empty); } }
@Override public void call(final Subscriber<? super Request> subscriber) { try { UriValidator.validate(topic, clientConfig.useStrictUriValidation()); } catch (WampError e) { subscriber.onError(e); return; } stateController.scheduler().execute(new Runnable() { @Override public void run() { // If the Subscriber unsubscribed in the meantime we return early if (subscriber.isUnsubscribed()) return; // Set subscription to completed if we are not connected if (!(stateController.currentState() instanceof SessionEstablishedState)) { subscriber.onCompleted(); return; } // Forward publish into the session SessionEstablishedState curState = (SessionEstablishedState)stateController.currentState(); curState.performRegisterProcedure(topic, subscriber); } }); } });
stateController.scheduler().execute(new Runnable() { @Override public void run() {
stateController.scheduler().execute(new Runnable() { @Override public void run() {
stateController.scheduler().execute(new Runnable() { @Override public void run() {
@Override public void onEnter(ClientState lastState) { if (lastState instanceof InitialState) { stateController.setExternalState(new WampClient.ConnectingState()); } // Check for valid number of connects assert (nrConnectAttempts != 0); // Decrease remaining number of reconnects if it's not infinite if (nrConnectAttempts > 0) nrConnectAttempts--; // Starts an connection attempt to the router connectionController = new QueueingConnectionController(stateController.scheduler(), new ClientConnectionListener(stateController)); try { connectingCon = stateController.clientConfig().connector().connect(stateController.scheduler(), this, connectionController); } catch (Exception e) { // Catch exceptions that can happen during creating the channel // These are normally signs that something is wrong with our configuration // Therefore we don't trigger retries stateController.setCloseError(e); stateController.setExternalState(new WampClient.DisconnectedState(e)); DisconnectedState newState = new DisconnectedState(stateController, e); // This is a reentrant call to setState. However it works as onEnter is the last call in setState stateController.setState(newState); } }
@Override public void onEnter(ClientState lastState) { if (lastState instanceof InitialState) { stateController.setExternalState(new WampClient.ConnectingState()); } // Check for valid number of connects assert (nrConnectAttempts != 0); // Decrease remaining number of reconnects if it's not infinite if (nrConnectAttempts > 0) nrConnectAttempts--; // Starts an connection attempt to the router connectionController = new QueueingConnectionController(stateController.scheduler(), new ClientConnectionListener(stateController)); try { connectingCon = stateController.clientConfig().connector().connect(stateController.scheduler(), this, connectionController); } catch (Exception e) { // Catch exceptions that can happen during creating the channel // These are normally signs that something is wrong with our configuration // Therefore we don't trigger retries stateController.setCloseError(e); stateController.setExternalState(new WampClient.DisconnectedState(e)); DisconnectedState newState = new DisconnectedState(stateController, e); // This is a reentrant call to setState. However it works as onEnter is the last call in setState stateController.setState(newState); } }
@Override public void onEnter(ClientState lastState) { if (lastState instanceof InitialState) { stateController.setExternalState(new WampClient.ConnectingState()); } // Check for valid number of connects assert (nrConnectAttempts != 0); // Decrease remaining number of reconnects if it's not infinite if (nrConnectAttempts > 0) nrConnectAttempts--; // Starts an connection attempt to the router connectionController = new QueueingConnectionController(stateController.scheduler(), new ClientConnectionListener(stateController)); try { connectingCon = stateController.clientConfig().connector().connect(stateController.scheduler(), this, connectionController); } catch (Exception e) { // Catch exceptions that can happen during creating the channel // These are normally signs that something is wrong with our configuration // Therefore we don't trigger retries stateController.setCloseError(e); stateController.setExternalState(new WampClient.DisconnectedState(e)); DisconnectedState newState = new DisconnectedState(stateController, e); // This is a reentrant call to setState. However it works as onEnter is the last call in setState stateController.setState(newState); } }