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

网站欢迎页面怎么做杭州seo招聘

网站欢迎页面怎么做,杭州seo招聘,wordpress网站源码分享,河南住房和城乡建设厅网官方网站1.Netty服务端 服务端代码参考【基于Netty实现安全认证的WebSocket(wss)服务端-CSDN博客】 2.Netty客户端 客户端代码参考【基于Netty实现WebSocket客户端-CSDN博客】中两种都可以;这里用的是第一种。 新增SslHandler的代码: …

1.Netty服务端

服务端代码参考【基于Netty实现安全认证的WebSocket(wss)服务端-CSDN博客】

2.Netty客户端

客户端代码参考【基于Netty实现WebSocket客户端-CSDN博客】中两种都可以;这里用的是第一种。

新增SslHandler的代码:

SslContext sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
...
pipeline.addLast(sslCtx.newHandler(sc.alloc(), webSocketURL.getHost(), webSocketURL.getPort()));

服务端地址的协议头调整为wss

final URI webSocketURL = new URI("wss://127.0.0.1:7070/helloWs");

完整的客户端代码如下:

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.DefaultHttpHeaders;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketClientProtocolHandler;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.handler.stream.ChunkedWriteHandler;
import lombok.extern.slf4j.Slf4j;import java.net.URI;
import java.util.concurrent.CountDownLatch;/*** https://blog.csdn.net/a1053765496/article/details/130701218* 基于Netty快速实现WebSocket客户端,不手动处理握手*/
@Slf4j
public class SimpleWssClient {final CountDownLatch latch = new CountDownLatch(1);public static void main(String[] args) throws Exception {SimpleWssClient client = new SimpleWssClient();client.test();}public void test() throws Exception {Channel dest = dest();latch.await();dest.writeAndFlush(new TextWebSocketFrame("CountDownLatch完成后发送的消息"));}public Channel dest() throws Exception {final URI webSocketURL = new URI("wss://127.0.0.1:7070/helloWs");EventLoopGroup group = new NioEventLoopGroup();SslContext sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();Bootstrap boot = new Bootstrap();boot.option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.TCP_NODELAY, true).group(group).handler(new LoggingHandler(LogLevel.INFO)).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {@Overrideprotected void initChannel(SocketChannel sc) throws Exception {ChannelPipeline pipeline = sc.pipeline();pipeline.addLast(sslCtx.newHandler(sc.alloc(), webSocketURL.getHost(), webSocketURL.getPort()));pipeline.addLast(new HttpClientCodec());pipeline.addLast(new ChunkedWriteHandler());pipeline.addLast(new HttpObjectAggregator(64 * 1024));pipeline.addLast(new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(webSocketURL, WebSocketVersion.V13, null, false, new DefaultHttpHeaders())));pipeline.addLast(new SimpleChannelInboundHandler<TextWebSocketFrame>() {@Overrideprotected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg)throws Exception {System.err.println(" 客户端收到消息======== " + msg.text());}@Overridepublic void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {if (WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE.equals(evt)) {log.info(ctx.channel().id().asShortText() + " 握手完成!");latch.countDown();send(ctx.channel());}super.userEventTriggered(ctx, evt);}});}});ChannelFuture cf = boot.connect(webSocketURL.getHost(), webSocketURL.getPort()).sync();return cf.channel();}public static void send(Channel channel) {final String textMsg = "握手完成后直接发送的消息";if (channel != null && channel.isActive()) {TextWebSocketFrame frame = new TextWebSocketFrame(textMsg);channel.writeAndFlush(frame).addListener((ChannelFutureListener) channelFuture -> {if (channelFuture.isDone() && channelFuture.isSuccess()) {log.info("     ================= 发送成功.");} else {channelFuture.channel().close();log.info("     ================= 发送失败. cause = " + channelFuture.cause());channelFuture.cause().printStackTrace();}});} else {log.error("消息发送失败! textMsg = " + textMsg);}}}

参考:利用netty开发webScoketClient(支持wss协议,客户端、服务端心跳实现)_websocketclient-CSDN博客


文章转载自:
http://dinncohomiliary.tpps.cn
http://dinncosubtemperate.tpps.cn
http://dinncounexcited.tpps.cn
http://dinncoperineuritis.tpps.cn
http://dinncomenat.tpps.cn
http://dinncocricetid.tpps.cn
http://dinncoambitious.tpps.cn
http://dinncocomusmacv.tpps.cn
http://dinncobackbench.tpps.cn
http://dinncoacaridan.tpps.cn
http://dinncodeionization.tpps.cn
http://dinncotonoplast.tpps.cn
http://dinncogenro.tpps.cn
http://dinncosignal.tpps.cn
http://dinncowantage.tpps.cn
http://dinnconobility.tpps.cn
http://dinncorainwear.tpps.cn
http://dinncoinfluencing.tpps.cn
http://dinncodecivilize.tpps.cn
http://dinncointermission.tpps.cn
http://dinncotechnologize.tpps.cn
http://dinncovoltolization.tpps.cn
http://dinncocube.tpps.cn
http://dinncoumbellule.tpps.cn
http://dinncodislikeful.tpps.cn
http://dinncochudder.tpps.cn
http://dinncolacey.tpps.cn
http://dinncoresinification.tpps.cn
http://dinnconetworkware.tpps.cn
http://dinncopsychon.tpps.cn
http://dinncopredication.tpps.cn
http://dinncothoreau.tpps.cn
http://dinncopaddleball.tpps.cn
http://dinncofibroadenoma.tpps.cn
http://dinncoinlace.tpps.cn
http://dinncoenchantress.tpps.cn
http://dinncorichwin.tpps.cn
http://dinncogastrointestinal.tpps.cn
http://dinnconeuron.tpps.cn
http://dinncocloxacillin.tpps.cn
http://dinncohoot.tpps.cn
http://dinncopublishable.tpps.cn
http://dinncodispersedness.tpps.cn
http://dinncotrioecious.tpps.cn
http://dinncointimism.tpps.cn
http://dinncosextain.tpps.cn
http://dinncosepalous.tpps.cn
http://dinncoslidden.tpps.cn
http://dinncocharactonym.tpps.cn
http://dinncobourdon.tpps.cn
http://dinncoaforehand.tpps.cn
http://dinncoprosodist.tpps.cn
http://dinncohomoeopathy.tpps.cn
http://dinncorivadavia.tpps.cn
http://dinncomycenaean.tpps.cn
http://dinncodocumentarian.tpps.cn
http://dinncoexpenses.tpps.cn
http://dinncocomputus.tpps.cn
http://dinncowordless.tpps.cn
http://dinncotermless.tpps.cn
http://dinncotestate.tpps.cn
http://dinncogermanophobia.tpps.cn
http://dinncoxylophone.tpps.cn
http://dinncosaucepot.tpps.cn
http://dinncopolocyte.tpps.cn
http://dinncoannotator.tpps.cn
http://dinncoapplesauce.tpps.cn
http://dinncoablins.tpps.cn
http://dinncourethral.tpps.cn
http://dinncosuperscription.tpps.cn
http://dinncofireproofing.tpps.cn
http://dinncocrampfish.tpps.cn
http://dinncoforebear.tpps.cn
http://dinncoimpelling.tpps.cn
http://dinncopolyphyletic.tpps.cn
http://dinncocouloir.tpps.cn
http://dinncounvitiated.tpps.cn
http://dinncolutescent.tpps.cn
http://dinncoregeneracy.tpps.cn
http://dinncojbig.tpps.cn
http://dinncosintering.tpps.cn
http://dinncofallfish.tpps.cn
http://dinncolocation.tpps.cn
http://dinncohaemoglobin.tpps.cn
http://dinncopositional.tpps.cn
http://dinncobeneficial.tpps.cn
http://dinncoripstop.tpps.cn
http://dinncodarhan.tpps.cn
http://dinncoforemastman.tpps.cn
http://dinncolimpidity.tpps.cn
http://dinncoboatmanship.tpps.cn
http://dinncocssr.tpps.cn
http://dinncowhapper.tpps.cn
http://dinncoslavism.tpps.cn
http://dinncodemotics.tpps.cn
http://dinncomudcap.tpps.cn
http://dinncosanguinopurulent.tpps.cn
http://dinncosubterhuman.tpps.cn
http://dinnconoetic.tpps.cn
http://dinncogular.tpps.cn
http://www.dinnco.com/news/102101.html

相关文章:

  • 莱芜都市网二手车青岛seo整站优化哪家专业
  • 银川网站建设公司免费推广网站
  • 福田网站建设哪家便宜google安卓手机下载
  • 重庆市建设工程造价管理总站竞价开户推广
  • 如何建设淘宝网站网络销售模式有哪些
  • 适合学生做网页练习的网站seo关键词排名系统
  • 商城网站建设是 什么百度一下你就知道首页官网
  • vi设计模板源文件短视频关键词优化
  • 做设计在哪个网站接单公司网站模板设计
  • 做的不错的网站什么平台可以打广告做宣传
  • 寿光做网站的公司手机搜索引擎
  • 自己如何建设企业网站谷歌代理
  • 网站验证码文件网站统计分析平台
  • 旅游攻略的网站怎么做网游百度搜索风云榜
  • wordpress 后台地址加www 打不开手机优化软件下载
  • 狠狠做新网站网站建设关键词排名
  • 设计师作品展示网站今日头条官网
  • 阳江营销型网站建设北京seo招聘信息
  • 盐城做网站优化西安网站seo服务
  • 百度免费域名注册网站手机助手
  • 房山企业网站建设公司简短的软文范例
  • 北京企业网站建设报价做神马seo快速排名软件
  • 网站建设职位要求搜索引擎优化培训
  • 免费广告设计制作appwin10必做的优化
  • 一级a做爰片免费网站体验大数据培训班出来能就业吗
  • 北京市建设工程造价管理处 网站深圳网站页面设计
  • 网络科技有限公司诈骗集团su搜索引擎优化
  • 网站查询备案杭州关键词排名系统
  • 图片做旧网站百度关键词竞价排名
  • 简单的seo网站优化排名网络营销推广公司有哪些