|
|
|
|
@ -4,18 +4,21 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
|
|
import io.netty.handler.codec.MessageToByteEncoder;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 昆船JSON版发送 首尾加上 < >
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class KescEncoder extends MessageToByteEncoder<KsecInfo> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void encode(ChannelHandlerContext channelHandlerContext, KsecInfo ksecInfo, ByteBuf byteBuf) throws Exception {
|
|
|
|
|
String body = "<" + JSONObject.toJSONString(ksecInfo) + ">";
|
|
|
|
|
log.info("发送消息:{}",body);
|
|
|
|
|
byteBuf.writeBytes(body.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|