Skip to content

Instantly share code, notes, and snippets.

@yongboy
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongboy/87b27ab59c9d2c2e8cfa to your computer and use it in GitHub Desktop.
Save yongboy/87b27ab59c9d2c2e8cfa to your computer and use it in GitHub Desktop.
@Sharable
public class MqttMessageWebSocketFrameEncoder extends
MessageToMessageEncoder<Message> {
@Override
protected void encode(ChannelHandlerContext ctx, Message msg,
List<Object> out) throws Exception {
if (msg == null)
return;
byte[] data = ((Message) msg).toBytes();
out.add(new BinaryWebSocketFrame(Unpooled.wrappedBuffer(data)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment