use of org.adbcj.postgresql.codec.frontend.AbstractFrontendMessage in project adbcj by mheath.
the class Encoder method handleDownstream.
public void handleDownstream(ChannelHandlerContext context, ChannelEvent event) throws Exception {
if (!(event instanceof MessageEvent)) {
context.sendDownstream(event);
return;
}
MessageEvent e = (MessageEvent) event;
Object message = e.getMessage();
boolean singleMessage = message instanceof AbstractFrontendMessage;
boolean multipleMessages = message instanceof AbstractFrontendMessage[];
if (!singleMessage && !multipleMessages) {
context.sendDownstream(event);
return;
}
ChannelBuffer buffer = ChannelBuffers.buffer(1024);
ChannelBufferOutputStream out = new ChannelBufferOutputStream(buffer);
if (singleMessage) {
encoder.encode(out, (AbstractFrontendMessage) e.getMessage());
} else {
encoder.encode(out, (AbstractFrontendMessage[]) e.getMessage());
}
Channels.write(context, e.getFuture(), buffer);
}
Aggregations