@Override protected void putResourceRecordData(IoBuffer ioBuffer, ResourceRecord resourceRecord) { if (!resourceRecord.get(DnsAttribute.IP_ADDRESS).equals("::1")) { throw new IllegalStateException("Only supposed to be used with IPV6 address of ::1"); } // encode the ::1 ioBuffer.put(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}); } }
/** * Generates response for non-versioned connections, such as those before FP9. * * @param input * incoming RTMP bytes * @return outgoing handshake */ private IoBuffer generateUnversionedHandshake(byte[] input) { log.debug("Using old style (un-versioned) handshake"); IoBuffer output = IoBuffer.allocate((Constants.HANDSHAKE_SIZE * 2) + 1); // 3073 // non-encrypted output.put(RTMPConnection.RTMP_NON_ENCRYPTED); // set server uptime in seconds output.putInt((int) Red5.getUpTime() / 1000); //0x01 output.position(Constants.HANDSHAKE_SIZE + 1); output.put(input); output.flip(); // fill S1 with handshake data (nearly all 0's) output.mark(); output.position(1); output.get(s1); output.reset(); return output; }
buffer.putString(packet.getElement().asXML(), encoder.get()); if (flashClient) { buffer.put((byte) '\0');
private void deliverRawText0(String text){ boolean errorDelivering = false; IoBuffer buffer = IoBuffer.allocate(text.length()); buffer.setAutoExpand(true); try { //Charset charset = Charset.forName(CHARSET); //buffer.putString(text, charset.newEncoder()); buffer.put(text.getBytes(StandardCharsets.UTF_8)); if (flashClient) { buffer.put((byte) '\0'); } buffer.flip(); ioSessionLock.lock(); try { ioSession.write(buffer); } finally { ioSessionLock.unlock(); } } catch (Exception e) { Log.debug("Error delivering raw text:\n" + text, e); errorDelivering = true; } // Attempt to close the connection if delivering text fails. if (errorDelivering) { close(); } }
/** * Decode data sent by the client. * * @param data * the data to decode * @return a list of decoded objects */ public List<?> decode(IoBuffer data) { log.debug("decode"); if (closing || state.getState() == RTMP.STATE_DISCONNECTED) { // connection is being closed, don't decode any new packets return Collections.EMPTY_LIST; } if (log.isTraceEnabled()) { log.trace("Current bytes read at decode: {}", data.limit()); } buffer.put(data); buffer.flip(); return decoder.decodeBuffer(this, buffer); }
result = IoBuffer.allocate(targetSize).setAutoExpand(true); for (PendingData pendingMessage : sendList) { result.put(pendingMessage.getBuffer()); Packet packet = pendingMessage.getPacket(); if (packet != null) {
WritableByteChannel raw = rawFos.getChannel(); IoBuffer header = IoBuffer.allocate(1); header.put((byte) (isClient ? 0x00 : 0x01)); header.flip(); headers.write(header.buf());
/** {@inheritDoc} */ @Override public void messageReceived(NextFilter next, IoSession session, Object message) throws Exception { // Create forwarding IO session IoSession forward = (IoSession) session.getAttribute(FORWARD_KEY); if (forward != null && forward.isConnected()) { if (message instanceof IoBuffer) { final IoBuffer buf = (IoBuffer) message; if (log.isDebugEnabled()) { log.debug("[{}] RAW >> {}", name, buf.getHexDump()); } IoBuffer copy = IoBuffer.allocate(buf.limit()); int limit = buf.limit(); copy.put(buf); copy.flip(); forward.write(copy); buf.flip(); buf.position(0); buf.limit(limit); } } next.messageReceived(session, message); }
@Override protected void putResourceRecordData(IoBuffer ioBuffer, ResourceRecord resourceRecord) { if (!resourceRecord.get(DnsAttribute.IP_ADDRESS).equals("::1")) { throw new IllegalStateException("Only supposed to be used with IPV6 address of ::1"); } // encode the ::1 ioBuffer.put(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}); } }
/** * {@inheritDoc} */ @Override public IoBuffer put(byte b) { buf.put(b); return this; }
/** * {@inheritDoc} */ @Override public IoBuffer put(byte[] src, int offset, int length) { buf.put(src, offset, length); return this; }
final byte[] bytes = msg.getBytes(); final IoBuffer buffer = allocator.allocate(bytes.length, true); buffer.put(bytes); buffer.flip();
/** * {@inheritDoc} */ @Override public void put(int index, IoBuffer other) { bb.position(index); bb.put(other); }
public void write(byte[] b, int off, int len) throws IOException { while (len > buffer.remaining()) { int nlen = buffer.remaining(); buffer.put(b, off, nlen); len -= nlen; off += nlen; send(); buffer = IoBuffer.allocate((64 * 1024) - 42); } buffer.put(b, off, len); } private void send() throws IOException {
@Override public void write(int b) throws IOException { IoBuffer buf = IoBuffer.allocate(1); buf.put((byte) b); buf.flip(); write(buf); }
@Override public void write(int b) throws IOException { IoBuffer buf = IoBuffer.allocate(1); buf.put((byte) b); buf.flip(); write(buf); }
public IoSessionInputStream(IoBuffer b) { buf = IoBuffer.allocate(b.limit()); buf.put(b); buf.flip(); } public IoSessionInputStream() {
public void append(IoBuffer in) { if (overflowPosition != 0) { discard(in); } else if (buf.position() > maxLineLength - in.remaining()) { overflowPosition = buf.position(); buf.clear(); discard(in); } else { getBuffer().put(in); } }