/** * Sends a ping request to the server. If the ping response is not received * within a reasonable time limit, notifyDisconnected() will be called. */ private void verifyConnected() { // in case we were in the middle of something already pingTimeout.cancel(); transmit(Collections.singletonList(MessageBuilder.createMessage() .toSubject("ServerEchoService") .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage())); pingTimeout.schedule(2500); }
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); } }
/** * Sends a ping request to the server. If the ping response is not received * within a reasonable time limit, notifyDisconnected() will be called. */ private void verifyConnected() { // in case we were in the middle of something already pingTimeout.cancel(); transmit(Collections.singletonList(MessageBuilder.createMessage() .toSubject("ServerEchoService") .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage())); pingTimeout.schedule(2500); }
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); } }