public class MBUDPChannel
extends io.netty.channel.AbstractChannel
因Netty4.1.x中对UDP的实现相对于MINA这样的框架来说,回归到了UDP协议的本色状态 (即极简设计),从设计上、性能上来说回归到了协议的本质(这也是为什么Netty4中有 关UDP的官方Demo代码几乎没有的原因,因为没太多的东西可演示的)。但对于应用层开发 (比如IM、消息推送等场景)来说,失去了很多的便利性。因为为了客户端的身份识别、鉴 权、安全性等等,肯定是要做到“伪连接”的存在(MINA2中称为Session),这样就可以识别 客户端的身份、请求的合法性,并通过超时机制来达到客户端无故退出(比如崩溃等)时 自动判定“连接”的断开,从而即时更新此客户端的在线状态等。而Netty4中的这种“伪连接“、 ”伪连接超时检测机制“等,通通无法直接实现,要想达到这一点,那都得自已来。
限定符和类型 | 字段和说明 |
---|---|
protected io.netty.channel.DefaultChannelConfig |
config |
protected io.netty.channel.ChannelMetadata |
metadata |
protected java.net.InetSocketAddress |
remote
本Channel对应的客户端IP+端口信息
|
protected MBUDPServerChannel |
serverchannel
对应的服务端Channel实例引用
|
限定符 | 构造器和说明 |
---|---|
protected |
MBUDPChannel(MBUDPServerChannel serverchannel,
java.net.InetSocketAddress remote)
构造方法。
|
限定符和类型 | 方法和说明 |
---|---|
protected void |
addBuffer(io.netty.buffer.ByteBuf buffer) |
io.netty.channel.ChannelConfig |
config() |
protected void |
doBeginRead()
对Channel读操作的准备工作。
|
protected void |
doBind(java.net.SocketAddress addr) |
protected void |
doClose() |
protected void |
doDisconnect() |
protected void |
doWrite(io.netty.channel.ChannelOutboundBuffer buffer) |
boolean |
isActive() |
protected boolean |
isCompatible(io.netty.channel.EventLoop eventloop) |
boolean |
isOpen() |
protected java.net.SocketAddress |
localAddress0() |
io.netty.channel.ChannelMetadata |
metadata() |
protected io.netty.channel.AbstractChannel.AbstractUnsafe |
newUnsafe() |
protected java.net.SocketAddress |
remoteAddress0() |
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doDeregister, doRegister, doShutdownOutput, equals, eventLoop, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, toString, unsafe, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
protected final io.netty.channel.ChannelMetadata metadata
protected final io.netty.channel.DefaultChannelConfig config
protected final MBUDPServerChannel serverchannel
protected final java.net.InetSocketAddress remote
protected MBUDPChannel(MBUDPServerChannel serverchannel, java.net.InetSocketAddress remote)
serverchannel
- 对应的服务端Channel实例引用remote
- 本Channel对应的客户端IP+端口信息public io.netty.channel.ChannelMetadata metadata()
public io.netty.channel.ChannelConfig config()
public boolean isActive()
public boolean isOpen()
protected void doClose() throws java.lang.Exception
doClose
在类中 io.netty.channel.AbstractChannel
java.lang.Exception
protected void doDisconnect() throws java.lang.Exception
doDisconnect
在类中 io.netty.channel.AbstractChannel
java.lang.Exception
protected void addBuffer(io.netty.buffer.ByteBuf buffer)
protected void doBeginRead() throws java.lang.Exception
doBeginRead
在类中 io.netty.channel.AbstractChannel
java.lang.Exception
protected void doWrite(io.netty.channel.ChannelOutboundBuffer buffer) throws java.lang.Exception
doWrite
在类中 io.netty.channel.AbstractChannel
java.lang.Exception
protected boolean isCompatible(io.netty.channel.EventLoop eventloop)
isCompatible
在类中 io.netty.channel.AbstractChannel
protected io.netty.channel.AbstractChannel.AbstractUnsafe newUnsafe()
newUnsafe
在类中 io.netty.channel.AbstractChannel
protected java.net.SocketAddress localAddress0()
localAddress0
在类中 io.netty.channel.AbstractChannel
protected java.net.SocketAddress remoteAddress0()
remoteAddress0
在类中 io.netty.channel.AbstractChannel
protected void doBind(java.net.SocketAddress addr) throws java.lang.Exception
doBind
在类中 io.netty.channel.AbstractChannel
java.lang.Exception