@Override public void flush() { try { websocketSession.getAsyncRemote().flushBatch(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public void send(final URI receiverUri, final byte[] message, final String tag) throws IOException { if (remotes.containsKey(receiverUri)) { final Async remote = remotes.get(receiverUri); remote.sendBinary(ByteBuffer.wrap(message)); remote.flushBatch(); } else { throw new IOException("Remote: " + receiverUri.toASCIIString() + " is currently not connected."); } }
@Override public void send(final URI receiverUri, final String message, final String tag) throws IOException { if (remotes.containsKey(receiverUri)) { final Async remote = remotes.get(receiverUri); remote.sendText(message); remote.flushBatch(); } else { throw new IOException("Remote: " + receiverUri.toASCIIString() + " is currently not connected. (" + getAddress() + " / " + remotes.keySet() + ")"); } }
@Override public void send(final URI receiverUri, final byte[] message, final String tag) throws IOException { if (!receiverUri.equals(serverUrl)) { throw new IOException( "Currently it's only possible to send to the server agent directly, not other agents:" + receiverUri.toASCIIString()); } if (remote == null || !isConnected()) { connect(); } if (remote != null) { try { remote.sendBinary(ByteBuffer.wrap(message)); remote.flushBatch(); } catch (RuntimeException rte) { if (rte.getMessage().equals("Socket is not connected.")) { remote = null; // retry! send(receiverUri, message, tag); } } } else { throw new IOException("Not connected?"); } }
@Override public void send(final URI receiverUri, final String message, final String tag) throws IOException { if (!receiverUri.equals(serverUrl)) { throw new IOException( "Currently it's only possible to send to the server agent directly, not other agents:" + receiverUri.toASCIIString() + " serverUrl:" + serverUrl.toASCIIString()); } if (remote == null || !isConnected()) { connect(); } if (remote != null) { try { remote.sendText(message); remote.flushBatch(); } catch (RuntimeException rte) { if (rte.getMessage().equals("Socket is not connected.")) { remote = null; // retry! send(receiverUri, message, tag); } } } else { throw new IOException("Not connected?"); } }
@Override public final void flush() { try { session.getAsyncRemote().flushBatch(); } catch (IOException e) { throw new UncheckedIOException(e); } }