Netty学习笔记一
来源:互联网 发布:it监控平台软件 编辑:程序博客网 时间:2024/05/01 23:26
Handler模块:
ChannelHandler:
{@link ChannelHandler} itself does not provide any method. To handle a
* {@link ChannelEvent} you need to implement its sub-interfaces. There are
* two sub-interfaces which handles a received event, one for upstream events
* and the other for downstream events
不提供任何方法,在应用中,要根据需要选择实现它的子接口:ChannelUpstreamHandler或者ChannelDownstreamHandler,或者两者的合成接口--SimpleChannelHandler(继承了ChannelUpstreamHandler接口和ChannelDownstreamHandler接口)
ChannelUpstreamHandler :【 extends ChannelHandler】
Handles or intercepts an upstream {@link ChannelEvent}, and sends a
{@link ChannelEvent} to the next handler in a {@link ChannelPipeline}.
The most common use case of this interface is to intercept an I/O event
generated by I/O workers to transform the received messages or execute
the relevant business logic.
ChannelDownstreamHandler:【 extends ChannelHandler】
Handles or intercepts a downstream {@link ChannelEvent}, and sends a
{@link ChannelEvent} to the next handler in a {@link ChannelPipeline}.
The most common use case of this interface is to intercept an I/O request
such as {@link Channel#write(Object)} and {@link Channel#close()}.
SimpleChannelHandler:【 implements ChannelUpstreamHandler, ChannelDownstreamHandler】
A {@link ChannelHandler} which provides an individual handler method
* for each event type. This handler down-casts the received upstream or
* or downstream event into more meaningful sub-type event and calls an
* appropriate handler method with the down-cast event.
SimpleChannelHandler提供了足够多的网络事件响应方法:
handleUpstream
messageReceived
exceptionCaught
channelOpen
channelBound
channelConnected
channelInterestChanged
channelDisconnected
channelUnbound
channelClosed
writeComplete
childChannelOpen
childChannelClosed
handleDownstream
writeRequested
bindRequested
connectRequested
setInterestOpsRequested
disconnectRequested
unbindRequested
closeRequested
大多数情况下,我们开发过程中要创建自己的ChannelHandler,一般实现自SimpleChannelHandler接口,覆盖里面相应的方法,或者创建自己的方法即可。
- 【Netty】netty学习笔记一
- Netty学习笔记一
- Netty 学习笔记一、Hello Netty
- Netty学习笔记(一) 配置Netty环境
- Netty学习笔记(一)
- netty学习笔记(一)
- Netty学习笔记(一)
- Java Netty 学习笔记(一)初识Netty
- Netty学习笔记一 项目demo
- Netty学习笔记(一)EchoServer服务器
- Netty自学-Netty学习(一)
- netty 学习记录一
- Netty学习(一)
- Netty学习(一)
- Netty 实例学习一
- Netty源码学习笔记
- Netty 学习笔记
- Netty学习笔记
- 说给青春听的那些语句,为什么总那么疼
- UIImagePickerController使用
- XNA游戏:对Content的理解
- Ubuntu安装Java环境
- 非常简单的进度条对话框
- Netty学习笔记一
- MAC下不错的 svn 软件 Cornerstone 2.0.0.15 最新版简体汉化
- Photoshop 使用技巧
- 浅谈12个内部链接的最佳优化实践
- 2-1000之间的完数
- poj 1936 字符匹配
- xcode快捷键
- 基于MyBatis3.0.6的基本操作介绍
- 提高效率、节省时间的十五法则