@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); BufferUtil.writeTo(payload,out); }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); // allow for fast fail of BAD utf (incomplete utf will trigger on messageComplete) this.utf.append(payload); }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); BufferUtil.writeTo(payload,out); }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } onEvent.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); // allow for fast fail of BAD utf (incomplete utf will trigger on messageComplete) this.utf.append(payload); }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } driver.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); synchronized (utf) { utf.append(payload); } if (needsNotification) { needsNotification = true; this.driver.onReader(this); } }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } driver.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); synchronized (utf) { utf.append(payload); } if (needsNotification) { needsNotification = true; this.driver.onReader(this); } }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } driver.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); synchronized (buf) { // TODO: grow buffer till max binary message size? // TODO: compact this buffer to fit incoming buffer? // TODO: tell connection to suspend if buffer too full? BufferUtil.put(payload,buf); } if (needsNotification) { needsNotification = true; this.driver.onInputStream(this); } }
@Override public void appendMessage(ByteBuffer payload) throws IOException { if (finished) { throw new IOException("Cannot append to finished buffer"); } if (payload == null) { // empty payload is valid return; } driver.getPolicy().assertValidMessageSize(size + payload.remaining()); size += payload.remaining(); synchronized (buf) { // TODO: grow buffer till max binary message size? // TODO: compact this buffer to fit incoming buffer? // TODO: tell connection to suspend if buffer too full? BufferUtil.put(payload,buf); } if (needsNotification) { needsNotification = true; this.driver.onInputStream(this); } }
private void assertSanePayloadLength(long len) { LOG.debug("Payload Length: " + len); // Since we use ByteBuffer so often, having lengths over Integer.MAX_VALUE is really impossible. if (len > Integer.MAX_VALUE) { // OMG! Sanity Check! DO NOT WANT! Won't anyone think of the memory! throw new MessageTooLargeException("[int-sane!] cannot handle payload lengths larger than " + Integer.MAX_VALUE); } policy.assertValidMessageSize((int)len); switch (frame.getOpCode()) { case OpCode.CLOSE: if (len == 1) { throw new ProtocolException("Invalid close frame payload length, [" + payloadLength + "]"); } // fall thru case OpCode.PING: case OpCode.PONG: if (len > WebSocketFrame.MAX_CONTROL_PAYLOAD) { throw new ProtocolException("Invalid control frame payload length, [" + payloadLength + "] cannot exceed [" + WebSocketFrame.MAX_CONTROL_PAYLOAD + "]"); } break; } }
private void assertSanePayloadLength(long len) { LOG.debug("Payload Length: " + len); // Since we use ByteBuffer so often, having lengths over Integer.MAX_VALUE is really impossible. if (len > Integer.MAX_VALUE) { // OMG! Sanity Check! DO NOT WANT! Won't anyone think of the memory! throw new MessageTooLargeException("[int-sane!] cannot handle payload lengths larger than " + Integer.MAX_VALUE); } policy.assertValidMessageSize((int)len); switch (frame.getOpCode()) { case OpCode.CLOSE: if (len == 1) { throw new ProtocolException("Invalid close frame payload length, [" + payloadLength + "]"); } // fall thru case OpCode.PING: case OpCode.PONG: if (len > WebSocketFrame.MAX_CONTROL_PAYLOAD) { throw new ProtocolException("Invalid control frame payload length, [" + payloadLength + "] cannot exceed [" + WebSocketFrame.MAX_CONTROL_PAYLOAD + "]"); } break; } }