public void sendPartialBytes(ByteBuffer partialByte, boolean last) throws IOException { if (partialByte == null) { throw new IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData")); } stateMachine.binaryPartialStart(); startMessageBlock(Constants.OPCODE_BINARY, partialByte, last); stateMachine.complete(last); }
public void sendBytesByCompletion(ByteBuffer data, SendHandler handler) { if (data == null) { throw new IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullData")); } if (handler == null) { throw new IllegalArgumentException(sm.getString("wsRemoteEndpoint.nullHandler")); } StateUpdateSendHandler sush = new StateUpdateSendHandler(handler, stateMachine); stateMachine.binaryStart(); startMessage(Constants.OPCODE_BINARY, data, true, sush); }
public synchronized void complete(boolean last) { if (last) { checkState(State.TEXT_PARTIAL_WRITING, State.TEXT_FULL_WRITING, State.BINARY_PARTIAL_WRITING, State.BINARY_FULL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); state = State.OPEN; } else { checkState(State.TEXT_PARTIAL_WRITING, State.BINARY_PARTIAL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); if (state == State.TEXT_PARTIAL_WRITING) { state = State.TEXT_PARTIAL_READY; } else if (state == State.BINARY_PARTIAL_WRITING){ state = State.BINARY_PARTIAL_READY; } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states // permitted by the preceding checkState() call throw new IllegalStateException( "BUG: This code should never be called"); } } }
public synchronized void complete(boolean last) { if (last) { checkState(State.TEXT_PARTIAL_WRITING, State.TEXT_FULL_WRITING, State.BINARY_PARTIAL_WRITING, State.BINARY_FULL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); state = State.OPEN; } else { checkState(State.TEXT_PARTIAL_WRITING, State.BINARY_PARTIAL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); if (state == State.TEXT_PARTIAL_WRITING) { state = State.TEXT_PARTIAL_READY; } else if (state == State.BINARY_PARTIAL_WRITING){ state = State.BINARY_PARTIAL_READY; } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states // permitted by the preceding checkState() call throw new IllegalStateException( "BUG: This code should never be called"); } } }
public synchronized void complete(boolean last) { if (last) { checkState(State.TEXT_PARTIAL_WRITING, State.TEXT_FULL_WRITING, State.BINARY_PARTIAL_WRITING, State.BINARY_FULL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); state = State.OPEN; } else { checkState(State.TEXT_PARTIAL_WRITING, State.BINARY_PARTIAL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); if (state == State.TEXT_PARTIAL_WRITING) { state = State.TEXT_PARTIAL_READY; } else if (state == State.BINARY_PARTIAL_WRITING){ state = State.BINARY_PARTIAL_READY; } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states // permitted by the preceding checkState() call throw new IllegalStateException( "BUG: This code should never be called"); } } }
public synchronized void complete(boolean last) { if (last) { checkState(State.TEXT_PARTIAL_WRITING, State.TEXT_FULL_WRITING, State.BINARY_PARTIAL_WRITING, State.BINARY_FULL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); state = State.OPEN; } else { checkState(State.TEXT_PARTIAL_WRITING, State.BINARY_PARTIAL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); if (state == State.TEXT_PARTIAL_WRITING) { state = State.TEXT_PARTIAL_READY; } else if (state == State.BINARY_PARTIAL_WRITING){ state = State.BINARY_PARTIAL_READY; } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states // permitted by the preceding checkState() call throw new IllegalStateException( "BUG: This code should never be called"); } } }
public synchronized void complete(boolean last) { if (last) { checkState(State.TEXT_PARTIAL_WRITING, State.TEXT_FULL_WRITING, State.BINARY_PARTIAL_WRITING, State.BINARY_FULL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); state = State.OPEN; } else { checkState(State.TEXT_PARTIAL_WRITING, State.BINARY_PARTIAL_WRITING, State.STREAM_WRITING, State.WRITER_WRITING); if (state == State.TEXT_PARTIAL_WRITING) { state = State.TEXT_PARTIAL_READY; } else if (state == State.BINARY_PARTIAL_WRITING){ state = State.BINARY_PARTIAL_READY; } else if (state == State.WRITER_WRITING) { // NO-OP. Leave state as is. } else if (state == State.STREAM_WRITING) { // NO-OP. Leave state as is. } else { // Should never happen // The if ... else ... blocks above should cover all states // permitted by the preceding checkState() call throw new IllegalStateException( "BUG: This code should never be called"); } } }
@Override public void onResult(SendResult result) { if (isDone) { endpoint.stateMachine.complete(isLast); handler.onResult(result); } else if(!result.isOK()) { handler.onResult(result); } else if (closed){ SendResult sr = new SendResult(new IOException( sm.getString("wsRemoteEndpoint.closedDuringMessage"))); handler.onResult(sr); } else { write(); } } }
@Override public void onResult(SendResult result) { if (isDone) { endpoint.stateMachine.complete(isLast); handler.onResult(result); } else if(!result.isOK()) { handler.onResult(result); } else if (closed){ SendResult sr = new SendResult(new IOException( sm.getString("wsRemoteEndpoint.closedDuringMessage"))); handler.onResult(sr); } else { write(); } } }
@Override public void onResult(SendResult result) { if (isDone) { endpoint.stateMachine.complete(isLast); handler.onResult(result); } else if(!result.isOK()) { handler.onResult(result); } else if (closed){ SendResult sr = new SendResult(new IOException( sm.getString("wsRemoteEndpoint.closedDuringMessage"))); handler.onResult(sr); } else { write(); } } }
@Override public void onResult(SendResult result) { if (isDone) { endpoint.stateMachine.complete(isLast); handler.onResult(result); } else if(!result.isOK()) { handler.onResult(result); } else if (closed){ SendResult sr = new SendResult(new IOException( sm.getString("wsRemoteEndpoint.closedDuringMessage"))); handler.onResult(sr); } else { write(); } } }
void sendMessageBlock(CharBuffer part, boolean last) throws IOException { long timeoutExpiry = getTimeoutExpiry(); boolean isDone = false; while (!isDone) { encoderBuffer.clear(); CoderResult cr = encoder.encode(part, encoderBuffer, true); if (cr.isError()) { throw new IllegalArgumentException(cr.toString()); } isDone = !cr.isOverflow(); encoderBuffer.flip(); sendMessageBlock(Constants.OPCODE_TEXT, encoderBuffer, last && isDone, timeoutExpiry); } stateMachine.complete(last); }
void sendMessageBlock(CharBuffer part, boolean last) throws IOException { long timeoutExpiry = getTimeoutExpiry(); boolean isDone = false; while (!isDone) { encoderBuffer.clear(); CoderResult cr = encoder.encode(part, encoderBuffer, true); if (cr.isError()) { throw new IllegalArgumentException(cr.toString()); } isDone = !cr.isOverflow(); encoderBuffer.flip(); sendMessageBlock(Constants.OPCODE_TEXT, encoderBuffer, last && isDone, timeoutExpiry); } stateMachine.complete(last); }
@Override public void onResult(SendResult result) { if (isDone) { endpoint.stateMachine.complete(isLast); handler.onResult(result); } else if(!result.isOK()) { handler.onResult(result); } else if (closed){ SendResult sr = new SendResult(new IOException(MESSAGES.messageRemainderSessionClosed())); handler.onResult(sr); } else { write(); } } }
public synchronized void textPartialStart() { checkState(State.OPEN, State.TEXT_PARTIAL_READY); state = State.TEXT_PARTIAL_WRITING; }
public synchronized void streamStart() { checkState(State.OPEN); state = State.STREAM_WRITING; }
public OutputStream getSendStream() { stateMachine.streamStart(); return new WsOutputStream(this); }
public Writer getSendWriter() { stateMachine.writeStart(); return new WsWriter(this); }
public synchronized void streamStart() { checkState(State.OPEN); state = State.STREAM_WRITING; }
public OutputStream getSendStream() { stateMachine.streamStart(); return new WsOutputStream(this); }