StompFrame frame = decoder.decode(buffer);
if (frame != null)
{
WebSocketFrame wsFrame = new DefaultWebSocketFrame(frame.asString());
// Text frame
ChannelBuffer data = wsFrame.getBinaryData();
ChannelBuffer encoded = channel.getConfig().getBufferFactory().getBuffer(data.order(),
data.readableBytes() + 2);
encoded.writeByte((byte)wsFrame.getType());
encoded.writeBytes(data, data.readableBytes());
encoded.writeByte((byte)0xFF);
return encoded;
}