Search in sources :

Example 1 with ClientRequest

use of org.adbcj.mysql.codec.ClientRequest in project adbcj by mheath.

the class Handler method handleDownstream.

public void handleDownstream(ChannelHandlerContext context, ChannelEvent event) throws Exception {
    if (!(event instanceof MessageEvent)) {
        context.sendDownstream(event);
        return;
    }
    MessageEvent e = (MessageEvent) event;
    if (!(e.getMessage() instanceof ClientRequest)) {
        context.sendDownstream(event);
        return;
    }
    ChannelBuffer buffer = ChannelBuffers.buffer(1024);
    ChannelBufferOutputStream out = new ChannelBufferOutputStream(buffer);
    encoder.encode((ClientRequest) e.getMessage(), out);
    Channels.write(context, e.getFuture(), buffer);
}
Also used : ChannelBufferOutputStream(org.jboss.netty.buffer.ChannelBufferOutputStream) MessageEvent(org.jboss.netty.channel.MessageEvent) ClientRequest(org.adbcj.mysql.codec.ClientRequest) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Aggregations

ClientRequest (org.adbcj.mysql.codec.ClientRequest)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1 ChannelBufferOutputStream (org.jboss.netty.buffer.ChannelBufferOutputStream)1 MessageEvent (org.jboss.netty.channel.MessageEvent)1