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);
}
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);
}
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();
}
}
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;
}
}
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);
}
}
}
Aggregations