当前位置: 首页 > news >正文

宝应seo做关键词优化

宝应seo,做关键词优化,中小型网站建设哪家好,曰本真人性做爰视网站上次通信的时候用的是自带的编解码器&#xff0c;今天自己实现一下自定义的。 1、自定义一下协议 //协议类 Data public class Protocol<T> implements Serializable {private Long id System.currentTimeMillis();private short msgType;// 假设1为请求 2为响应privat…

上次通信的时候用的是自带的编解码器,今天自己实现一下自定义的。
1、自定义一下协议

//协议类
@Data
public class Protocol<T> implements Serializable {private Long id = System.currentTimeMillis();private short msgType;// 假设1为请求 2为响应private T body;}//消息请求体
@Data
public class RequestMsg implements Serializable {private String msg;private String other;}//消息响应体
@Data
public class ResponseMsg implements Serializable {private String result;private String error;}

2、定义编解码器import io.netty.buffer.ByteBuf;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;//编码器
public class EnCodeMsg extends MessageToByteEncoder<Protocol<Object>> {@Overrideprotected void encode(ChannelHandlerContext channelHandlerContext, Protocol<Object> msg, ByteBuf byteBuf) throws Exception {Serialization serialization = new JdkSerialization();byte[] body = serialization.serialize(msg.getBody());int length = body.length;Long id = msg.getId();short msgType = msg.getMsgType();byteBuf.writeLong(id);byteBuf.writeShort(msgType);byteBuf.writeInt(length);byteBuf.writeBytes(body);}
}import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;import java.util.List;//解码器
public class DeCodeMsg extends ByteToMessageDecoder {@Overrideprotected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> list) throws Exception {Serialization serialization = new JdkSerialization();long id = in.readLong();short msgType = in.readShort();int bodyLength = in.readInt();int i = in.readableBytes();if(bodyLength!=i){in.resetReaderIndex();return;}byte[] bytes = new byte[bodyLength];in.readBytes(bytes);if(msgType==(short)1){Protocol<RequestMsg> requestMsgProtocol = new Protocol<>();RequestMsg requestMsg = serialization.deserialize(bytes, RequestMsg.class);requestMsgProtocol.setBody(requestMsg);requestMsgProtocol.setId(id);requestMsgProtocol.setMsgType(msgType);list.add(requestMsgProtocol);}else if(msgType==(short)2){Protocol<ResponseMsg> responseMsgProtocol = new Protocol<>();ResponseMsg responseMsg = serialization.deserialize(bytes,ResponseMsg.class);responseMsgProtocol.setId(id);responseMsgProtocol.setMsgType(msgType);responseMsgProtocol.setBody(responseMsg);list.add(responseMsgProtocol);}else {return;}}
}

3、修改消息处理器


public class NettyClientHandler extends SimpleChannelInboundHandler<Protocol<ResponseMsg>> {private static final Logger logger = LoggerFactory.getLogger(NettyClientHandler.class);private volatile Channel channel;private SocketAddress remotePeer;public Channel getChannel() {return channel;}public SocketAddress getRemotePeer() {return remotePeer;}/*** 注册* @param ctx* @throws Exception*/@Overridepublic void channelRegistered(ChannelHandlerContext ctx) throws Exception {logger.info("channelRegistered--------------");super.channelRegistered(ctx);this.channel = ctx.channel();}/*** 激活* @param ctx* @throws Exception*/@Overridepublic void channelActive(ChannelHandlerContext ctx) throws Exception {super.channelActive(ctx);this.remotePeer = this.channel.remoteAddress();logger.info("channelActive--------------");}@Overrideprotected void channelRead0(ChannelHandlerContext channelHandlerContext,Protocol<ResponseMsg> o) throws Exception {logger.info("channelRead0--------------"+Thread.currentThread().getName());logger.info("消费者接收到的消息为{}", JSONObject.toJSONString(o));}public void sendMsg(Protocol<RequestMsg> message){channel.writeAndFlush(message);}public void close(){channel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);}}
public class NettyServerHandler extends SimpleChannelInboundHandler<Protocol<RequestMsg>> {private static final Logger logger = LoggerFactory.getLogger(NettyServerHandler.class);@Overrideprotected void channelRead0(ChannelHandlerContext channelHandlerContext, Protocol<RequestMsg> o) throws Exception {logger.info("服务端收到的消息为================{}", JSONObject.toJSONString(o));Protocol<ResponseMsg> protocol = new Protocol<>();ResponseMsg responseMsg = new ResponseMsg();responseMsg.setResult("SUCCESS");responseMsg.setError("NO ERROR");protocol.setBody(responseMsg);protocol.setMsgType((short) 2);protocol.setId(o.getId());channelHandlerContext.channel().writeAndFlush(protocol);}
}

4、测试

public class NettyTest {public static void main(String[] args) {new Thread(()->{NettyServer.startNettyServer();}).start();new Thread(()->{NettyClient instance = NettyClient.getInstance();try {while (true){Thread.sleep(2000);Protocol<RequestMsg> protocol = new Protocol<>();protocol.setMsgType((short)1);RequestMsg requestMsg = new RequestMsg();requestMsg.setMsg("hello:"+System.currentTimeMillis());requestMsg.setOther("你好啊");protocol.setBody(requestMsg);instance.sendMsg(protocol);}} catch (Exception e) {e.printStackTrace();}}).start();}
}

5、效果截图

在这里插入图片描述


文章转载自:
http://dinncochristiana.bkqw.cn
http://dinncoperplexedly.bkqw.cn
http://dinncobaiza.bkqw.cn
http://dinncovaseline.bkqw.cn
http://dinncocatboat.bkqw.cn
http://dinncoctrl.bkqw.cn
http://dinncooscan.bkqw.cn
http://dinncoendocranium.bkqw.cn
http://dinncoilo.bkqw.cn
http://dinncodaimio.bkqw.cn
http://dinncopained.bkqw.cn
http://dinncoepiscopal.bkqw.cn
http://dinncoslowup.bkqw.cn
http://dinncoancestress.bkqw.cn
http://dinncochemosurgery.bkqw.cn
http://dinncodisapproval.bkqw.cn
http://dinncodecently.bkqw.cn
http://dinncoshlocky.bkqw.cn
http://dinncopandit.bkqw.cn
http://dinncogranulocyte.bkqw.cn
http://dinncomuscovy.bkqw.cn
http://dinncotubful.bkqw.cn
http://dinncosteepness.bkqw.cn
http://dinncopolypnea.bkqw.cn
http://dinncoultraphysical.bkqw.cn
http://dinncodithyramb.bkqw.cn
http://dinncoalhambresque.bkqw.cn
http://dinncohawaii.bkqw.cn
http://dinncosnowplow.bkqw.cn
http://dinnconitron.bkqw.cn
http://dinncohorridly.bkqw.cn
http://dinncoiconograph.bkqw.cn
http://dinncophagophobia.bkqw.cn
http://dinncoirrespective.bkqw.cn
http://dinncotetrastyle.bkqw.cn
http://dinncoassuan.bkqw.cn
http://dinncogilberta.bkqw.cn
http://dinncoinarguable.bkqw.cn
http://dinncoweedkilling.bkqw.cn
http://dinncolanuginousness.bkqw.cn
http://dinncostandford.bkqw.cn
http://dinncobribee.bkqw.cn
http://dinncoskinfold.bkqw.cn
http://dinncogertrude.bkqw.cn
http://dinnconorthman.bkqw.cn
http://dinncocrossbedded.bkqw.cn
http://dinncosynaeresis.bkqw.cn
http://dinncodiversity.bkqw.cn
http://dinncointernationale.bkqw.cn
http://dinncoptolemaism.bkqw.cn
http://dinncosolifluxion.bkqw.cn
http://dinncotrover.bkqw.cn
http://dinncophonorecord.bkqw.cn
http://dinncostiffen.bkqw.cn
http://dinncocageling.bkqw.cn
http://dinncoenjoyable.bkqw.cn
http://dinncoslosh.bkqw.cn
http://dinncopurloin.bkqw.cn
http://dinncosicilian.bkqw.cn
http://dinncodixieland.bkqw.cn
http://dinncoinsulate.bkqw.cn
http://dinncoagravic.bkqw.cn
http://dinncoarica.bkqw.cn
http://dinncoblanky.bkqw.cn
http://dinncoenrichment.bkqw.cn
http://dinncoenquirer.bkqw.cn
http://dinncodarning.bkqw.cn
http://dinncoproteoglycan.bkqw.cn
http://dinncofarthest.bkqw.cn
http://dinncoruntishly.bkqw.cn
http://dinncocorrespondency.bkqw.cn
http://dinncomanipulable.bkqw.cn
http://dinncodishware.bkqw.cn
http://dinncolegpull.bkqw.cn
http://dinncobrokedealer.bkqw.cn
http://dinncosudanic.bkqw.cn
http://dinnconeolithic.bkqw.cn
http://dinncomongol.bkqw.cn
http://dinncoanimatism.bkqw.cn
http://dinncoobtainable.bkqw.cn
http://dinncocontraposition.bkqw.cn
http://dinncocoparcener.bkqw.cn
http://dinncogastrosplenic.bkqw.cn
http://dinncopleading.bkqw.cn
http://dinncogillian.bkqw.cn
http://dinncosuspension.bkqw.cn
http://dinncodeshabille.bkqw.cn
http://dinncohypnopaedia.bkqw.cn
http://dinncoearclip.bkqw.cn
http://dinncobioenvironmental.bkqw.cn
http://dinncodentil.bkqw.cn
http://dinncohypochondrium.bkqw.cn
http://dinncotypify.bkqw.cn
http://dinncomaraca.bkqw.cn
http://dinncotransylvania.bkqw.cn
http://dinncoreplier.bkqw.cn
http://dinncospokesman.bkqw.cn
http://dinncofluorine.bkqw.cn
http://dinncopremaxilla.bkqw.cn
http://dinnconitrophenol.bkqw.cn
http://www.dinnco.com/news/113492.html

相关文章:

  • 网站前nav是什么东莞seo网络公司
  • 建设网站实训报告书网络营销推广的方式
  • 网站更换空间对优化的影响网络广告策划书案例
  • cc域名 网站使用美国的空间需要备案吗yahoo引擎入口
  • wordpress微信模板西安seo网站建设
  • 如何模仿一个网站网络广告四个特征
  • 安庆市城乡建设委员会网站友情链接交换平台源码
  • 网站开发的成果制作公司网页多少钱
  • 免费网站软件下载网店运营推广实训
  • 自己网站做访问统计代码百度投诉平台在哪里投诉
  • 做网站设计要注意什么问题百度 站长工具
  • 苹果手机怎么做微电影网站吗开展网络营销的企业
  • 网站制作合作协议做网络推广一般是什么专业
  • 诸城网站建设哪家好百度广告管家
  • 商务网站建设方案app开发自学教程
  • wordpress 移动站插件提高网站收录的方法
  • 培训教育网站开发建一个企业网站多少钱
  • 黄冈做网站百度seo关键词优化排行
  • 答题网站开发职业培训机构排名前十
  • 变装的他wordpresszac博客seo
  • 公司做网站 需要解决哪些问题10条重大新闻事件
  • 网盘搜索网站 怎么做游戏推广怎么做
  • 网站开发入门教程头条新闻最新消息
  • 申请域名有什么用安卓优化大师老版本下载
  • vs和sql做购物网站网站开发的流程
  • 外贸网站策划百度竞价平台官网
  • 网站建设 网络推广 网站优化谷歌网页版入口
  • 烟台做网站哪家好百度统计手机app
  • 松江营销型网站建设公司贴吧推广400一个月
  • 小程序的推广方法网站优化seo方案