@Override public void sendBlocking(byte[] data, int start, int length) throws IOException { synchronized (this) { try { websocketSession.getBasicRemote().sendBinary(ByteBuffer.wrap(data, start, length)); } catch (IOException e) { // Ignore } } }
public void execute(Object command) throws BuildAgentClientException { log.info("Executing remote command [{}]...", command); javax.websocket.RemoteEndpoint.Basic remoteEndpoint = commandExecutingEndpoint.getRemoteEndpoint(); ByteBuffer byteBuffer = prepareRemoteCommand(command); try { log.debug("Sending remote command..."); remoteEndpoint.sendBinary(byteBuffer); log.debug("Command sent."); } catch (IOException e) { log.error("Cannot execute remote command.", e); } }
void send(Event event) { connect(); log.debug("Sending Event: {}", event); synchronized (session) { try { session .getBasicRemote() .sendBinary(ByteBuffer.wrap(mapper.writeValueAsBytes(event))); } catch (IOException e) { throw new UncheckedIOException(e); } } }
@Override public void sendBinary(byte[] message) { try { session.getBasicRemote().sendBinary(ByteBuffer.wrap(message)); } catch (IOException ex) { Log.Warn(this, ex); try { close(); } catch (IOException e) { Log.Warn(this, ex); } } }
@Override protected void sendBinaryMessage(BinaryMessage message) throws IOException { getNativeSession().getBasicRemote().sendBinary(message.getPayload(), message.isLast()); }
/** * Invoked on send partial binary message event. * * @param message data to be sent. * @param isLast {@code true} when the partial message being sent is the last part of the message. * @throws IOException if there is a problem delivering the message. */ public void onSendBinary(byte[] message, boolean isLast) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(message), isLast); }
@Override public void sendBinary(byte[] bytes) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(bytes)); }
@Override public void sendBytes(byte[] data) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(data)); } }
@Override public synchronized IWebSocketConnection sendMessage(byte[] message, int offset, int length) throws IOException { checkClosed(); ByteBuffer buf = ByteBuffer.wrap(message, offset, length); session.getBasicRemote().sendBinary(buf); return this; }
/** * Invoked on send binary message event. * * @param message data to be sent. * @throws IOException if there is a problem delivering the message. */ public void onSendBinary(byte[] message) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(message)); }
@Override public void sendBytes(byte[] data) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(data)); } }
public static void executeRemoteCommand(Client client, String command) { log.info("Executing remote command ..."); RemoteEndpoint.Basic remoteEndpoint = client.getRemoteEndpoint(); String data = "{\"action\":\"read\",\"data\":\"" + command + "\\r\\n\"}"; try { remoteEndpoint.sendBinary(ByteBuffer.wrap(data.getBytes())); } catch (IOException e) { e.printStackTrace(); } } }
public static void executeRemoteCommand(Client client, String command) { log.info("Executing remote command ..."); RemoteEndpoint.Basic remoteEndpoint = client.getRemoteEndpoint(); String data = "{\"action\":\"read\",\"data\":\"" + command + "\\r\\n\"}"; try { remoteEndpoint.sendBinary(ByteBuffer.wrap(data.getBytes())); } catch (IOException e) { e.printStackTrace(); } } }
/** * Invoked on send binary message event. * * @param message data to be sent. * @throws IOException if there is a problem delivering the message. */ public void onSendBinary(byte[] message) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(message)); }
public static void executeRemoteCommand(Client client, String command) { log.info("Executing remote command ..."); RemoteEndpoint.Basic remoteEndpoint = client.getRemoteEndpoint(); String data = "{\"action\":\"read\",\"data\":\"" + command + "\\r\\n\"}"; try { remoteEndpoint.sendBinary(ByteBuffer.wrap(data.getBytes())); } catch (IOException e) { e.printStackTrace(); } } }
@OnMessage public void onByteMessage(Session session, ByteBuffer message) { System.out.println(svrName+" onByteMessage "+message.array().length+" bytes"); try { session.getBasicRemote().sendBinary(message); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // "echo" response }
/** * Invoked on send partial binary message event. * * @param message data to be sent. * @param isLast {@code true} when the partial message being sent is the last part of the message. * @throws IOException if there is a problem delivering the message. */ public void onSendBinary(byte[] message, boolean isLast) throws IOException { session.getBasicRemote().sendBinary(ByteBuffer.wrap(message), isLast); }
@Override public synchronized IWebSocketConnection sendMessage(byte[] message, int offset, int length) throws IOException { checkClosed(); ByteBuffer buf = ByteBuffer.wrap(message, offset, length); session.getBasicRemote().sendBinary(buf); return this; }
@Override public void sendBlocking(ByteBuffer data) throws IOException { synchronized (this) { try { websocketSession.getBasicRemote().sendBinary(data); } catch (IOException e) { // Ignore } } }
@Override protected void sendBinaryMessage(BinaryMessage message) throws IOException { getNativeSession().getBasicRemote().sendBinary(message.getPayload(), message.isLast()); }