/** * Is called after the low-level connection between the client and the server was established */ void sendHelloMessage() { // System.out.println("Session websocket connection established"); // Connection to the remote host was established // However the WAMP session is not established until the handshake was finished connectionController .sendMessage(new WampMessages.HelloMessage(stateController.clientConfig().realm(), stateController.clientConfig().helloDetails()), IWampConnectionPromise.Empty); }
/** * Publishes an event under the given topic. * @param topic The topic that should be used for publishing the event * @param args A list of all positional arguments of the event to publish. * These will be get serialized according to the Jackson library serializing * behavior. * @return An observable that provides a notification whether the event * publication was successful. This contains either a single value (the * publication ID) and will then be completed or will be completed with * an error if the event could not be published. */ public Observable<Long> publish(final String topic, Object... args) { return publish(topic, ArgArrayBuilder.buildArgumentsArray(clientConfig.objectMapper(), args), null); }
/** Returns the URI of the router to which this client is connected */ public URI routerUri() { return clientConfig.routerUri(); }
List<ClientSideAuthentication> authMethods = stateController.clientConfig().authMethods(); authMethod.handleChallenge(challenge, stateController.clientConfig().objectMapper()); if (reply == null) { handleProtocolError();
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 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 onEnter(ClientState lastState) { reconnectSubscription = stateController.rxScheduler().createWorker().schedule(new Action0() { @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); }
/** Returns the name of the realm on the router */ public String realm() { return clientConfig.realm(); }
@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); } }
new ClientConfiguration( closeOnErrors, authId, authMethods, routerUri, realm, useStrictUriValidation, rolesArray, nrReconnects, reconnectInterval,
List<ClientSideAuthentication> authMethods = stateController.clientConfig().authMethods(); authMethod.handleChallenge(challenge, stateController.clientConfig().objectMapper()); if (reply == null) { handleProtocolError();
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 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 onEnter(ClientState lastState) { reconnectSubscription = stateController.rxScheduler().createWorker().schedule(new Action0() { @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); }
/** Returns the name of the realm on the router */ public String realm() { return clientConfig.realm(); }
@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); } }
new ClientConfiguration( closeOnErrors, authId, authMethods, routerUri, realm, useStrictUriValidation, rolesArray, nrReconnects, reconnectInterval,
/** * Publishes an event under the given topic. * @param topic The topic that should be used for publishing the event * @param args A list of all positional arguments of the event to publish. * These will be get serialized according to the Jackson library serializing * behavior. * @return An observable that provides a notification whether the event * publication was successful. This contains either a single value (the * publication ID) and will then be completed or will be completed with * an error if the event could not be published. */ public Observable<Long> publish(final String topic, Object... args) { return publish(topic, ArgArrayBuilder.buildArgumentsArray(clientConfig.objectMapper(), args), null); }
/** * Is called after the low-level connection between the client and the server was established */ void sendHelloMessage() { // System.out.println("Session websocket connection established"); // Connection to the remote host was established // However the WAMP session is not established until the handshake was finished connectionController .sendMessage(new WampMessages.HelloMessage(stateController.clientConfig().realm(), stateController.clientConfig().helloDetails()), IWampConnectionPromise.Empty); }
List<ClientSideAuthentication> authMethods = stateController.clientConfig().authMethods(); authMethod.handleChallenge(challenge, stateController.clientConfig().objectMapper()); if (reply == null) { handleProtocolError();