Search in sources :

Example 11 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project streamsx.topology by IBMStreams.

the class TestTupleEncoder method encode.

@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
    TestTuple tuple = (TestTuple) message;
    IoBuffer buffer = IoBuffer.allocate(4 + 4 + tuple.getTupleData().length);
    buffer.putInt(tuple.getTesterId());
    buffer.putInt(tuple.getTupleData().length);
    buffer.put(tuple.getTupleData());
    buffer.flip();
    out.write(buffer);
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 12 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project adbcj by mheath.

the class MysqlMessageEncoder method encode.

@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput encoderOut) throws Exception {
    IoBuffer buffer = IoBuffer.allocate(1024);
    OutputStream out = buffer.asOutputStream();
    try {
        encoder.encode((ClientRequest) message, out);
    } finally {
        out.close();
    }
    buffer.flip();
    encoderOut.write(buffer);
}
Also used : OutputStream(java.io.OutputStream) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 13 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project Openfire by igniterealtime.

the class NIOConnection method deliverRawText0.

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));
        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();
    }
}
Also used : UnauthorizedException(org.jivesoftware.openfire.auth.UnauthorizedException) UnknownHostException(java.net.UnknownHostException) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 14 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project zm-mailbox by Zimbra.

the class MilterHandler method getDataBuffer.

private IoBuffer getDataBuffer(MilterPacket command) {
    byte[] data = command.getData();
    if (data != null && data.length > 0) {
        IoBuffer buf = IoBuffer.allocate(data.length, false);
        buf.put(data);
        buf.flip();
        return buf;
    } else {
        return null;
    }
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 15 with IoBuffer

use of org.apache.mina.core.buffer.IoBuffer in project zm-mailbox by Zimbra.

the class MilterHandler method SMFIC_Macro.

private void SMFIC_Macro(MilterPacket command) throws IOException {
    ZimbraLog.milter.debug("SMFIC_Macro");
    IoBuffer data = getDataBuffer(command);
    if (data != null) {
        byte cmd = data.get();
        if ((char) cmd == 'M') {
            getAddrFromMacro(data, MACRO_MAIL_ADDR, Context.SENDER);
        } else if ((char) cmd == 'R') {
            getAddrFromMacro(data, MACRO_RCPT_ADDR, Context.RECIPIENT);
        }
    }
}
Also used : IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Aggregations

IoBuffer (org.apache.mina.core.buffer.IoBuffer)49 Test (org.junit.Test)8 VideoData (org.red5.server.net.rtmp.event.VideoData)4 UnknownHostException (java.net.UnknownHostException)3 HashMap (java.util.HashMap)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 AudioData (org.red5.server.net.rtmp.event.AudioData)3 Gson (com.google.gson.Gson)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 CharacterCodingException (java.nio.charset.CharacterCodingException)2 Exchange (org.apache.camel.Exchange)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 Message (ca.uhn.hl7v2.model.Message)1 AddressedEnvelope (io.netty.channel.AddressedEnvelope)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)1 DatagramPacket (io.netty.channel.socket.DatagramPacket)1