Created
May 20, 2014 14:28
-
-
Save yongboy/0bb76623f2a45d82bbf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.mqtt.handler.coder; | |
import io.netty.buffer.Unpooled; | |
import io.netty.channel.ChannelHandler.Sharable; | |
import io.netty.channel.ChannelHandlerContext; | |
import io.netty.handler.codec.MessageToMessageEncoder; | |
import java.util.List; | |
import org.meqantt.message.Message; | |
@Sharable | |
public class MqttMessageNewEncoder extends MessageToMessageEncoder<Object> { | |
@Override | |
protected void encode(ChannelHandlerContext ctx, Object msg, | |
List<Object> out) throws Exception { | |
if (!(msg instanceof Message)) { | |
return; | |
} | |
byte[] data = ((Message) msg).toBytes(); | |
out.add(Unpooled.wrappedBuffer(data)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment