/** * Not message frames - ping/pong/... */ /* package */ final Future<Frame> send(TyrusFrame frame) { return send(frame, null, true); }
/** * Not message frames - ping/pong/... */ /* package */ final Future<Frame> send(TyrusFrame frame) { return send(frame, null, true); }
/** * Send a text frame to the remote endpoint. * * @param data data to be sent. * @return {@link Future} which could be used to control/check the sending completion state. */ public Future<Frame> sendText(String data) { checkConnectedState(); return protocolHandler.send(data); }
/** * Send a text frame to the remote endpoint. * * @param data data to be sent. * @param handler {@link SendHandler#onResult(javax.websocket.SendResult)} will be called when sending is complete. */ public void sendText(String data, SendHandler handler) { checkConnectedState(); protocolHandler.send(data, handler); }
/** * Send a binary frame to the remote endpoint. * * @param data data to be sent. * @return {@link Future} which could be used to control/check the sending completion state. */ public Future<Frame> sendBinary(byte[] data) { checkConnectedState(); return protocolHandler.send(data); }
/** * Send a binary frame to the remote endpoint. * * @param data data to be sent. * @return {@link Future} which could be used to control/check the sending completion state. */ public Future<Frame> sendBinary(byte[] data) { checkConnectedState(); return protocolHandler.send(data); }
/** * Send a binary frame to the remote endpoint. * * @param data data to be sent. * @param handler {@link SendHandler#onResult(javax.websocket.SendResult)} will be called when sending is complete. */ public void sendBinary(byte[] data, SendHandler handler) { checkConnectedState(); protocolHandler.send(data, handler); }
/** * Send a binary frame to the remote endpoint. * * @param data data to be sent. * @param handler {@link SendHandler#onResult(javax.websocket.SendResult)} will be called when sending is complete. */ public void sendBinary(byte[] data, SendHandler handler) { checkConnectedState(); protocolHandler.send(data, handler); }
/** * Send a text frame to the remote endpoint. * * @param data data to be sent. * @return {@link Future} which could be used to control/check the sending completion state. */ public Future<Frame> sendText(String data) { checkConnectedState(); return protocolHandler.send(data); }
/** * Send a text frame to the remote endpoint. * * @param data data to be sent. * @param handler {@link SendHandler#onResult(javax.websocket.SendResult)} will be called when sending is complete. */ public void sendText(String data, SendHandler handler) { checkConnectedState(); protocolHandler.send(data, handler); }
private Future<Frame> send(TyrusFrame frame) { checkConnectedState(); return protocolHandler.send(frame); }
private Future<Frame> send(TyrusFrame frame) { checkConnectedState(); return protocolHandler.send(frame); }
/** * Raw frame is always whole (not partial). * * @param data serialized frame. * @return send future. */ public Future<Frame> sendRawFrame(ByteBuffer data) { lock.lock(); try { checkSendingFragment(); return send(data, null, true); } finally { lock.unlock(); } }
/** * Raw frame is always whole (not partial). * * @param data serialized frame. * @return send future. */ public Future<Frame> sendRawFrame(ByteBuffer data) { lock.lock(); try { checkSendingFragment(); return send(data, null, true); } finally { lock.unlock(); } }
public Future<Frame> send(String data) { lock.lock(); try { checkSendingFragment(); return send(new TextFrame(data, false, true)); } finally { lock.unlock(); } }
public Future<Frame> send(String data) { lock.lock(); try { checkSendingFragment(); return send(new TextFrame(data, false, true)); } finally { lock.unlock(); } }
public Future<Frame> send(byte[] data) { lock.lock(); try { checkSendingFragment(); return send(new BinaryFrame(data, false, true), null, true); } finally { lock.unlock(); } }
public Future<Frame> send(byte[] data) { lock.lock(); try { checkSendingFragment(); return send(new BinaryFrame(data, false, true), null, true); } finally { lock.unlock(); } }
public void send(final byte[] data, final SendHandler handler) { lock.lock(); try { checkSendingFragment(); send(new BinaryFrame(data, false, true), new CompletionHandler<Frame>() { @Override public void failed(Throwable throwable) { handler.onResult(new SendResult(throwable)); } @Override public void completed(Frame result) { handler.onResult(new SendResult()); } }, true); } finally { lock.unlock(); } }
public synchronized Future<Frame> close(final int code, final String reason) { final CloseFrame outgoingCloseFrame; final CloseReason closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(code), reason); if (code == CloseReason.CloseCodes.NO_STATUS_CODE.getCode() || code == CloseReason.CloseCodes.CLOSED_ABNORMALLY.getCode() || code == CloseReason.CloseCodes.TLS_HANDSHAKE_FAILURE.getCode() // client side cannot send SERVICE_RESTART or TRY_AGAIN_LATER // will be replaced with NORMAL_CLOSURE || (client && (code == CloseReason.CloseCodes.SERVICE_RESTART.getCode() || code == CloseReason.CloseCodes.TRY_AGAIN_LATER.getCode()))) { outgoingCloseFrame = new CloseFrame(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, reason)); } else { outgoingCloseFrame = new CloseFrame(closeReason); } final Future<Frame> send = send(outgoingCloseFrame, null, false); webSocket.onClose(new CloseFrame(closeReason)); return send; }