void startMessageBlock(byte opCode, ByteBuffer payload, boolean last) throws IOException { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); startMessage(opCode, payload, last, f2sh); try { if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new IOException(e); } }
public Future<Void> sendObjectByFuture(Object obj) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendObjectByCompletion(obj, f2sh); return f2sh; }
if (state == State.OPEN || f2sh.isCloseMessage()) { if (f2sh.isDone()) { f2sh.onResult(sr);
/** * WebSocket 1.0. Section 2.1.5. * Need internal close method as spec requires that the local endpoint * receives a 1006 on timeout. */ private void doClose(CloseReason closeReasonMessage, CloseReason closeReasonLocal) { // Double-checked locking. OK because state is volatile if (state != State.OPEN) { return; } synchronized (stateLock) { if (state != State.OPEN) { return; } state = State.CLOSING; sendCloseMessage(closeReasonMessage); fireEndpointOnClose(closeReasonLocal); state = State.CLOSED; } IOException ioe = new IOException(sm.getString("wsSession.messageFailed")); SendResult sr = new SendResult(ioe); for (FutureToSendHandler f2sh : futures.keySet()) { f2sh.onResult(sr); } }
public Future<Void> sendObjectByFuture(Object obj) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendObjectByCompletion(obj, f2sh); return f2sh; }
SendResult sr = new SendResult(ioe); for (FutureToSendHandler f2sh : futures.keySet()) { f2sh.onResult(sr);
void startMessageBlock(byte opCode, ByteBuffer payload, boolean last) throws IOException { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); startMessage(opCode, payload, last, f2sh); try { if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } // FIXME: maybe not needed if (payload != null) { payload.clear(); } } catch (InterruptedException e) { throw new IOException(e); } catch (ExecutionException e) { throw new IOException(e); } catch (TimeoutException e) { throw new IOException(e); } }
public Future<Void> sendBytesByFuture(ByteBuffer data) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendBytesByCompletion(data, f2sh); return f2sh; }
SendResult sr = new SendResult(ioe); for (FutureToSendHandler f2sh : futures.keySet()) { f2sh.onResult(sr);
void sendPartialString(CharBuffer part, boolean last) throws IOException { try { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); TextMessageSendHandler tmsh = new TextMessageSendHandler(f2sh, part, last, encoder, encoderBuffer, this); tmsh.write(); if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new IOException(e); } }
public Future<Void> sendObjectByFuture(Object obj) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendObjectByCompletion(obj, f2sh); return f2sh; }
SendResult sr = new SendResult(ioe); for (FutureToSendHandler f2sh : futures.keySet()) { f2sh.onResult(sr);
void startMessageBlock(byte opCode, ByteBuffer payload, boolean last) throws IOException { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession, opCode == Constants.OPCODE_CLOSE); startMessage(opCode, payload, last, f2sh); try { if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException e) { handleSendFailure(e); } catch (ExecutionException e) { throw new IOException(e); } catch (TimeoutException e) { throw new IOException(e); } }
public Future<Void> sendStringByFuture(String text) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendStringByCompletion(text, f2sh); return f2sh; }
SendResult sr = new SendResult(ioe); for (FutureToSendHandler f2sh : futures.keySet()) { f2sh.onResult(sr);
void sendPartialString(CharBuffer part, boolean last) throws IOException { try { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); TextMessageSendHandler tmsh = new TextMessageSendHandler(f2sh, part, last, encoder, encoderBuffer, this); tmsh.write(); if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException e) { throw new IOException(e); } catch (ExecutionException e) { throw new IOException(e); } catch (TimeoutException e) { throw new IOException(e); } }
public Future<Void> sendBytesByFuture(ByteBuffer data) { FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); sendBytesByCompletion(data, f2sh); return f2sh; }
void sendPartialString(CharBuffer part, boolean last) throws IOException { try { // Get the timeout before we send the message. The message may // trigger a session close and depending on timing the client // session may close before we can read the timeout. long timeout = getBlockingSendTimeout(); FutureToSendHandler f2sh = new FutureToSendHandler(wsSession); TextMessageSendHandler tmsh = new TextMessageSendHandler(f2sh, part, last, encoder, encoderBuffer, this); tmsh.write(); if (timeout == -1) { f2sh.get(); } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } } catch (InterruptedException e) { handleSendFailure(e); } catch (ExecutionException e) { throw new IOException(e); } catch (TimeoutException e) { throw new IOException(e); } }