91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.56MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-11-04
  • 語言: 其他
  • 標簽: netty??

資源簡介

來自于瘋狂創客圈 《netty+protobuf 整合實戰》的源代碼,付上了 protobuf 的 protoc 工具, protoc-2.6.1-win32.zip

資源截圖

代碼片段和文件信息

package?com.crazymakercircle.chat.client;

import?com.crazymakercircle.chat.common.ClientMsgBuilder;
import?com.crazymakercircle.chat.common.Session;
import?com.crazymakercircle.chat.common.bean.ChatMsg;
import?com.crazymakercircle.chat.common.bean.User;
import?com.crazymakercircle.chat.common.bean.msg.ProtoMsg;
import?com.crazymakercircle.chat.common.codec.ProtobufDecoder;
import?com.crazymakercircle.chat.common.codec.ProtobufEncoder;
import?com.crazymakercircle.util;
import?io.netty.bootstrap.Bootstrap;
import?io.netty.buffer.PooledByteBufAllocator;
import?io.netty.channel.*;
import?io.netty.channel.nio.NioEventLoopGroup;
import?io.netty.channel.socket.SocketChannel;
import?io.netty.channel.socket.nio.NioSocketChannel;
import?io.netty.util.AttributeKey;
import?org.slf4j.Logger;
import?org.slf4j.LoggerFactory;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.beans.factory.annotation.Value;
import?org.springframework.stereotype.Service;

import?java.util.Date;
import?java.util.Scanner;
import?java.util.concurrent.TimeUnit;

@Service(“EchoClient“)
public?class?ChatClient
{
????static?final?Logger?LOGGER?=
????????????LoggerFactory.getLogger(ChatClient.class);
????//?服務器ip地址
????@Value(“${server.ip}“)
????private?String?host;
????//?服務器端口
????@Value(“${server.port}“)
????private?int?port;

????//?通過nio方式來接收連接和處理連接
????private?EventLoopGroup?group?=?new?NioEventLoopGroup();

????@Autowired
????private?ChatClientHandler?chatClientHandler;

????private?Channel?channel;
????private?User?user;

????/**
?????*?唯一標記
?????*/
????private?boolean?initFalg?=?true;

????/**
?????*?客戶端的是Bootstrap,服務端的則是?ServerBootstrap。
?????*?都是AbstractBootstrap的子類。
?????**/
????public?void?run()
????{
????????doConnect(new?Bootstrap()?group);
????}

????/**
?????*?重連
?????*/
????public?void?doConnect(Bootstrap?bootstrap?EventLoopGroup?eventLoopGroup)
????{
????????ChannelFuture?f?=?null;
????????try
????????{
????????????if?(bootstrap?!=?null)
????????????{
????????????????bootstrap.group(eventLoopGroup);
????????????????bootstrap.channel(NioSocketChannel.class);
????????????????bootstrap.option(ChannelOption.SO_KEEPALIVE?true);
????????????????bootstrap.option(ChannelOption.ALLOCATOR?PooledByteBufAllocator.DEFAULT);
????????????????bootstrap.remoteAddress(host?port);

????????????????//?設置通道初始化
????????????????bootstrap.handler(
????????????????????????new?ChannelInitializer()
????????????????????????{
????????????????????????????public?void?initChannel(SocketChannel?ch)?throws?Exception
????????????????????????????{
????????????????????????????????ch.pipeline().addLast(new?ProtobufDecoder());
????????????????????????????????ch.pipeline().addLast(new?ProtobufEncoder());
????????????????????????????????ch.pipeline().addLast(chatClientHandler);

????????????????????????????}
????????????????????????}
????????????????);

??????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-09?22:10??.git\
?????文件???????????7??2018-11-07?23:36??.git\COMMIT_EDITMSG
?????文件??????????23??2018-11-07?20:14??.git\HEAD
?????文件?????????334??2018-11-09?13:58??.git\config
?????文件??????????73??2018-11-07?20:14??.git\description
?????目錄???????????0??2018-11-07?20:14??.git\hooks\
?????文件?????????478??2018-11-07?20:14??.git\hooks\applypatch-msg.sample
?????文件?????????896??2018-11-07?20:14??.git\hooks\commit-msg.sample
?????文件????????3327??2018-11-07?20:14??.git\hooks\fsmonitor-watchman.sample
?????文件?????????189??2018-11-07?20:14??.git\hooks\post-update.sample
?????文件?????????424??2018-11-07?20:14??.git\hooks\pre-applypatch.sample
?????文件????????1638??2018-11-07?20:14??.git\hooks\pre-commit.sample
?????文件????????1348??2018-11-07?20:14??.git\hooks\pre-push.sample
?????文件????????4898??2018-11-07?20:14??.git\hooks\pre-rebase.sample
?????文件?????????544??2018-11-07?20:14??.git\hooks\pre-receive.sample
?????文件????????1492??2018-11-07?20:14??.git\hooks\prepare-commit-msg.sample
?????文件????????3610??2018-11-07?20:14??.git\hooks\update.sample
?????文件????????3688??2018-11-09?19:50??.git\index
?????目錄???????????0??2018-11-07?20:14??.git\info\
?????文件?????????240??2018-11-07?20:14??.git\info\exclude
?????目錄???????????0??2018-11-07?21:14??.git\logs\
?????文件?????????452??2018-11-07?23:36??.git\logs\HEAD
?????目錄???????????0??2018-11-07?21:59??.git\logs\refs\
?????目錄???????????0??2018-11-07?21:14??.git\logs\refs\heads\
?????文件?????????452??2018-11-07?23:36??.git\logs\refs\heads\master
?????目錄???????????0??2018-11-07?21:59??.git\logs\refs\remotes\
?????目錄???????????0??2018-11-07?21:59??.git\logs\refs\remotes\origin\
?????文件?????????280??2018-11-07?23:37??.git\logs\refs\remotes\origin\master
?????目錄???????????0??2018-11-09?19:50??.git\objects\
?????目錄???????????0??2018-11-09?19:06??.git\objects\00\
?????文件?????????333??2018-11-09?19:19??.git\objects\00\171e92085186cd48e7309af953de24fe0ccc4e
............此處省略462個文件信息

評論

共有 條評論