netty 常用类 5.0.0.Alpha1

简介: 5.0版本较之前有很大改动,如java文件的包名等。 bootstrap io.netty.bootstrap.ServerBootstrap 服务端通道,ServerChannel,的导引。 Bootstrap sub-class which allows easy bootstrap of ServerChannel channel io.netty.channel.Cha

5.0版本较之前有很大改动,如java文件的包名等。

bootstrap

io.netty.bootstrap.ServerBootstrap
服务端通道,ServerChannel,的导引。
Bootstrap sub-class which allows easy bootstrap of ServerChannel

channel

io.netty.channel. ChannelFuture
通道,Channel,异步IO操作的结果。
The result of an asynchronous Channel I/O operation. 

io.netty.channel. ChannelInitializer
一个特殊的通道处理器,一旦一个Channel被注册到了它的EventLoop,ChannelInitializer用于初始化Channel。
A special ChannelHandler which offers an easy way to initialize a Channel once it was registered to its EventLoop.

Open Declaration io.netty.channel. ChannelOption
用于配置一个通道配置,ChannelConfig。
A ChannelOption allows to configure a ChannelConfig in a type-safe way. 


io.netty.channel.socket. SocketChannel
TCP 套接字的Channel。
A TCP/IP socket Channel.

io.netty.channel. EventLoopGroup
EventExecutorGroup的具体类。允许在时间循环中注册选择器。
Special EventExecutorGroup which allows to register Channel's that get processed for later selection during the event loop.

ChannelPipeline io.netty.channel.Channel. pipeline()
返回已分配的管道,ChannelPipeline。
Return the assigned ChannelPipeline

ChannelPipeline io.netty.channel.ChannelPipeline. addLast(ChannelHandler... handlers)
在管道末尾插入一个通道处理器,ChannelHandler。
Inserts a ChannelHandlers at the last position of this pipeline.

io.netty.channel. ChannelHandler
通道处理器,用于处理一个IO事件或者拦截一个IO操作。
Handles an I/O event or intercepts an I/O operation, and forwards it to its next handler in its ChannelPipeline. 

io.netty.channel. ChannelHandlerAdapter
一个通道处理器,ChannelHandler,的实现。
Skelton implementation of a ChannelHandler.

channel.ChannelHandlerContext

ChannelFuture io.netty.channel.ChannelHandlerContext. write(Object msg)
通过对应的 管道,ChannelPipeline,写消息。此方法不会进行冲洗,flush,所以你需要自己调用。
Request to write a message via this ChannelHandlerContext through the ChannelPipeline. This method will not request to actual flush, so be sure to call flush() once you want to request to flush all pending data to the actual transport.

buffer

io.netty.buffer. Unpooled
通过申请新的内存来创建一个新的字节缓冲。
Creates a new ByteBuf by allocating new space or by wrapping or copying existing byte arrays, byte buffers and a string. 

ByteBuf io.netty.buffer.Unpooled. copiedBuffer(byte[] array)
返回一个新的字节缓冲,内容是指定的array参数。
Creates a new big-endian buffer whose content is a copy of the specified array. The new buffer's readerIndex and writerIndex are 0 and array.length respectively.
目录
相关文章
|
存储 前端开发 网络协议
Netty入门到超神系列-Netty入门&核心类
我们需要有GoosGroup来循环监听请求事件,需要有WorkGroup来处理事件,而这两个角色都通过来就NioEventLoopGroup来进行事件监听,我们还需要创建事件处理器ChannelHandler,通过 Channel的ChannelPipeline把ChannelHandler进行关联。
112 0
|
监控 前端开发 Java
netty案例,netty4.1源码分析篇六《Netty异步架构监听类Promise源码分析》
Netty是一个异步网络处理框架,在实现中大量使用了Future机制,并在Java自带Future的基础上,增加了Promise机制。这两个实现类的目的都是为了使异步编程更加方便使用。
277 0
netty案例,netty4.1源码分析篇六《Netty异步架构监听类Promise源码分析》
|
存储 缓存 NoSQL
跟着源码学IM(十一):一套基于Netty的分布式高可用IM详细设计与实现(有源码)
本文将要分享的是如何从零实现一套基于Netty框架的分布式高可用IM系统,它将支持长连接网关管理、单聊、群聊、聊天记录查询、离线消息存储、消息推送、心跳、分布式唯一ID、红包、消息同步等功能,并且还支持集群部署。
13434 1
|
4月前
|
消息中间件 Oracle Dubbo
Netty 源码共读(一)如何阅读JDK下sun包的源码
Netty 源码共读(一)如何阅读JDK下sun包的源码
109 1
|
9月前
|
NoSQL Java Redis
跟着源码学IM(十二):基于Netty打造一款高性能的IM即时通讯程序
关于Netty网络框架的内容,前面已经讲了两个章节,但总归来说难以真正掌握,毕竟只是对其中一个个组件进行讲解,很难让诸位将其串起来形成一条线,所以本章中则会结合实战案例,对Netty进行更深层次的学习与掌握,实战案例也并不难,一个非常朴素的IM聊天程序。 原本打算做个多人斗地主练习程序,但那需要织入过多的业务逻辑,因此一方面会带来不必要的理解难度,让案例更为复杂化,另一方面代码量也会偏多,所以最终依旧选择实现基本的IM聊天程序,既简单,又能加深对Netty的理解。
141 1
|
4月前
|
编解码 前端开发 网络协议
Netty Review - ObjectEncoder对象和ObjectDecoder对象解码器的使用与源码解读
Netty Review - ObjectEncoder对象和ObjectDecoder对象解码器的使用与源码解读
96 0
|
4月前
|
编解码 安全 前端开发
Netty Review - StringEncoder字符串编码器和StringDecoder 解码器的使用与源码解读
Netty Review - StringEncoder字符串编码器和StringDecoder 解码器的使用与源码解读
163 0
|
11月前
|
分布式计算 网络协议 前端开发
【Netty底层数据交互源码】
【Netty底层数据交互源码】
|
11月前
|
Java 容器
【深入研究NIO与Netty线程模型的源码】
【深入研究NIO与Netty线程模型的源码】
|
编解码 弹性计算 缓存
Netty源码和Reactor模型
Netty源码和Reactor模型
91 0