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

企业网站建设基本标准能看男女做那个的网站

企业网站建设基本标准,能看男女做那个的网站,珠海公司网站制作公,课题网站建设验收总结报告1.Netty服务端 服务端代码参考【基于Netty实现安全认证的WebSocket#xff08;wss#xff09;服务端-CSDN博客】 2.Netty客户端 客户端代码参考【基于Netty实现WebSocket客户端-CSDN博客】中两种都可以#xff1b;这里用的是第一种。 新增SslHandler的代码#xff1a; …1.Netty服务端 服务端代码参考【基于Netty实现安全认证的WebSocketwss服务端-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 ChannelInitializerSocketChannel() {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 SimpleChannelInboundHandlerTextWebSocketFrame() {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://www.hkea.cn/news/14435869/

相关文章:

  • 做网站那个公司好竞价托管推广代运营
  • 制作网页教程的方法我自己的网站怎么做关键词优化
  • 做中介最好用的网站企业网站开发背景及意义
  • 来个手机能看的网站2021做网站小编怎么样
  • 电子商务网站建设花费国外以紫色为背景的网站
  • 阿里云网站备案查询高端做网站价格
  • ps做网页怎么在网站上打开防蚊手环移动网站建设
  • 网站导航页设计qq网站建设
  • 网站策划专员网站建立的链接不安全怎么解决
  • 设计介绍人的网站北京商标注册公司
  • 如何规划电子商务网站互联网技术的特征
  • 购买域名后如何建设网站古典网站案例
  • 宝塔怎么做第二个网站免费的行情网站app入口
  • 统计局宣传工作总结 网站建设中国核工业二三建设有限公司待遇
  • asp网站如何打开网络营销推广方式包括
  • 温州网站搭建泰安房产网站
  • 泰安网站建设介绍网站做中秋专题怎么弄
  • 国内做网站俄语网站里做外贸shop
  • wordpress 转发北京seo专业团队
  • 网站定制报价表百度关键词排名查询工具
  • idea建设完整的网站凡科建站登录
  • 网站有利于seo的细节指定网站建设前期规划方案
  • 南阳seo网站建设费用企业网站下周
  • 企业进行网站建设的方式淮安市建设监理协会网站
  • 陕西城乡建设网站wordpress内页无法打开
  • 仿站是什么意思生活类网站内容建设
  • 国内oa系统十大排名大连网站优化步骤
  • 泉州建网站dedecms 做影网站
  • 网站制作详细流程惠州seo排名优化
  • 漳浦县城乡规划建设局网站定制头像软件