@Override public void run() { setState(BusState.CONNECTION_INTERRUPTED); } }.schedule(ms);
/** * Puts the bus in the given state, firing all necessary transition events with no <tt>reason</tt> field. */ public void setState(final BusState newState) { setState(newState, null); }
private void notifyConnected() { if (connectedTime == -1) { connectedTime = System.currentTimeMillis(); } if (messageBus.getState() == BusState.CONNECTION_INTERRUPTED) messageBus.setState(BusState.CONNECTED); rxRetries = 0; }
private void notifyConnected() { pingTimeout.cancel(); retries = 0; if (!connected) { connected = true; connectedTime = System.currentTimeMillis(); logger.info(this + ": SSE channel is active."); } if (clientMessageBus.getState() == BusState.CONNECTION_INTERRUPTED) { clientMessageBus.setState(BusState.CONNECTED); } }
private void notifyDisconnected() { logger.info("websocket disconnected"); messageBus.setState(BusState.CONNECTION_INTERRUPTED); disconnectSocket(webSocketChannel); webSocketChannel = null; connectedTime = -1; if (!stopped) { retries++; new Timer() { @Override public void run() { logger.info("attempting reconnection ... "); longPollingTransport.stop(false); start(); } }.schedule(retries * 1000); } }
public boolean handleTransportError(final BusTransportError transportError) { for (final TransportErrorHandler handler : transportErrorHandlers) { handler.onError(transportError); } if (!transportError.isStopDefaultErrorHandler()) { if (state == BusState.CONNECTED) { setState(BusState.CONNECTION_INTERRUPTED, transportError); } else if (state != BusState.CONNECTING && state != BusState.CONNECTION_INTERRUPTED) { logger.error("got a transport error while in the " + state + " state"); } } return transportError.isStopDefaultErrorHandler(); }
private void stop(final boolean sendDisconnect, final TransportError reason) { logger.info("stopping bus ..."); if (initialConnectTimer != null) { initialConnectTimer.cancel(); } if (degradeToUnitialized()) { setState(BusState.UNINITIALIZED); deferredMessages.clear(); remotes.clear(); deferredSubscriptions.clear(); } else if (state != BusState.LOCAL_ONLY) { setState(BusState.LOCAL_ONLY, reason); } // Optionally tell the server we're going away (this causes two POST requests) if (sendDisconnect && isRemoteCommunicationEnabled()) { encodeAndTransmit(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(BusCommand.Disconnect) .set(MessageParts.PriorityProcessing, "1")); } deferredMessages.addAll(transportHandler.stop(true)); }
private void notifyDisconnected() { connected = false; pingTimeout.cancel(); logger.info(this + " channel disconnected."); connectedTime = -1; clientMessageBus.setState(BusState.CONNECTION_INTERRUPTED); disconnect(sseChannel); if (!stopped) { if (retries == 0) { transmit(Collections.singletonList(MessageBuilder.createMessage() .toSubject("ServerEchoService") .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage())); } final int retryDelay = Math.min((retries * 1000) + 1, 10000); logger.info("attempting SSE reconnection in " + retryDelay + "ms -- attempt: " + (++retries)); new Timer() { @Override public void run() { if (!stopped) { start(); } } }.schedule(retryDelay); } }
/** * Puts the bus in the given state, firing all necessary transition events with no <tt>reason</tt> field. */ public void setState(final BusState newState) { setState(newState, null); }
@Override public void handleProtocolExtension(final Message message) { switch (BusCommand.valueOf(message.getCommandType())) { case WebsocketChannelVerify: logger.info("received verification token for websocket connection"); longPollingTransport .transmit(Collections.singletonList(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(BusCommand.WebsocketChannelVerify) .copy(MessageParts.WebSocketToken, message))); break; case WebsocketChannelOpen: if (messageBus.getState() == BusState.CONNECTION_INTERRUPTED) messageBus.setState(BusState.CONNECTED); // send final message to open the channel transmitToSocket(webSocketChannel, getWebSocketNegotiationString()); longPollingTransport.stop(false); webSocketToken = message.get(String.class, MessageParts.WebSocketToken); logger.info("web socket channel successfully negotiated. comet channel deactivated. (reconnect token: " + webSocketToken + ")"); retries = 0; break; case WebsocketNegotiationFailed: hosed = true; unsupportedReason = "Negotiation Failed (Bad Key)"; disconnectSocket(webSocketChannel); webSocketChannel = null; messageBus.reconsiderTransport(); break; } }
@Override public void run() { setState(BusState.CONNECTION_INTERRUPTED); } }.schedule(ms);
setState(BusState.CONNECTED); sendAllDeferred(); InitVotes.voteFor(ClientMessageBus.class);
private void notifyConnected() { if (connectedTime == -1) { connectedTime = System.currentTimeMillis(); } if (messageBus.getState() == BusState.CONNECTION_INTERRUPTED) messageBus.setState(BusState.CONNECTED); rxRetries = 0; }
private void notifyConnected() { pingTimeout.cancel(); retries = 0; if (!connected) { connected = true; connectedTime = System.currentTimeMillis(); logger.info(this + ": SSE channel is active."); } if (clientMessageBus.getState() == BusState.CONNECTION_INTERRUPTED) { clientMessageBus.setState(BusState.CONNECTED); } }
private void notifyDisconnected() { logger.info("websocket disconnected"); messageBus.setState(BusState.CONNECTION_INTERRUPTED); disconnectSocket(webSocketChannel); webSocketChannel = null; connectedTime = -1; if (!stopped) { retries++; new Timer() { @Override public void run() { logger.info("attempting reconnection ... "); longPollingTransport.stop(false); start(); } }.schedule(retries * 1000); } }
public boolean handleTransportError(final BusTransportError transportError) { for (final TransportErrorHandler handler : transportErrorHandlers) { handler.onError(transportError); } if (!transportError.isStopDefaultErrorHandler()) { if (state == BusState.CONNECTED) { setState(BusState.CONNECTION_INTERRUPTED, transportError); } else if (state != BusState.CONNECTING && state != BusState.CONNECTION_INTERRUPTED) { logger.error("got a transport error while in the " + state + " state"); } } return transportError.isStopDefaultErrorHandler(); }
private void stop(final boolean sendDisconnect, final TransportError reason) { logger.info("stopping bus ..."); if (initialConnectTimer != null) { initialConnectTimer.cancel(); } if (degradeToUnitialized()) { setState(BusState.UNINITIALIZED); deferredMessages.clear(); remotes.clear(); deferredSubscriptions.clear(); } else if (state != BusState.LOCAL_ONLY) { setState(BusState.LOCAL_ONLY, reason); } // Optionally tell the server we're going away (this causes two POST requests) if (sendDisconnect && isRemoteCommunicationEnabled()) { encodeAndTransmit(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(BusCommand.Disconnect) .set(MessageParts.PriorityProcessing, "1")); } deferredMessages.addAll(transportHandler.stop(true)); }
private void notifyDisconnected() { connected = false; pingTimeout.cancel(); logger.info(this + " channel disconnected."); connectedTime = -1; clientMessageBus.setState(BusState.CONNECTION_INTERRUPTED); disconnect(sseChannel); if (!stopped) { if (retries == 0) { transmit(Collections.singletonList(MessageBuilder.createMessage() .toSubject("ServerEchoService") .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage())); } final int retryDelay = Math.min((retries * 1000) + 1, 10000); logger.info("attempting SSE reconnection in " + retryDelay + "ms -- attempt: " + (++retries)); new Timer() { @Override public void run() { if (!stopped) { start(); } } }.schedule(retryDelay); } }
@Override public void handleProtocolExtension(final Message message) { switch (BusCommand.valueOf(message.getCommandType())) { case WebsocketChannelVerify: logger.info("received verification token for websocket connection"); longPollingTransport .transmit(Collections.singletonList(CommandMessage.create() .toSubject(BuiltInServices.ServerBus.name()).command(BusCommand.WebsocketChannelVerify) .copy(MessageParts.WebSocketToken, message))); break; case WebsocketChannelOpen: if (messageBus.getState() == BusState.CONNECTION_INTERRUPTED) messageBus.setState(BusState.CONNECTED); // send final message to open the channel transmitToSocket(webSocketChannel, getWebSocketNegotiationString()); longPollingTransport.stop(false); webSocketToken = message.get(String.class, MessageParts.WebSocketToken); logger.info("web socket channel successfully negotiated. comet channel deactivated. (reconnect token: " + webSocketToken + ")"); retries = 0; break; case WebsocketNegotiationFailed: hosed = true; unsupportedReason = "Negotiation Failed (Bad Key)"; disconnectSocket(webSocketChannel); webSocketChannel = null; messageBus.reconsiderTransport(); break; } }