} else {
ChannelFuture handshake = this.handshaker.handshake(ctx.getChannel(), req);
if (handshake.isSuccess()) {
// we need to insert an encoder that takes the underlying ChannelBuffer of a StompFrame.toHornetQBuffer and
// wrap it in a binary web socket frame before letting the wsencoder send it on the wire
ctx.getPipeline().addAfter("wsencoder", "binary-websocket-encoder", new OneToOneEncoder() {
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (msg instanceof ChannelBuffer) {
return new BinaryWebSocketFrame((ChannelBuffer) msg);
}