本文整理汇总了Java中io.netty.channel.ChannelFuture.addListeners方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelFuture.addListeners方法的具体用法?Java ChannelFuture.addListeners怎么用?Java ChannelFuture.addListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.ChannelFuture
的用法示例。
在下文中一共展示了ChannelFuture.addListeners方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchPacket
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
* Will commit the packet to the channel. If the current thread 'owns' the channel it will write and flush the
* packet, otherwise it will add a task for the channel eventloop thread to do that.
*/
private void dispatchPacket(final Packet inPacket, final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
{
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(attrKeyConnectionState).get();
if (enumconnectionstate1 != enumconnectionstate)
{
logger.debug("Disabled auto read");
this.channel.config().setAutoRead(false);
}
if (this.channel.eventLoop().inEventLoop())
{
if (enumconnectionstate != enumconnectionstate1)
{
this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture.addListeners(futureListeners);
}
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
else
{
this.channel.eventLoop().execute(new Runnable()
{
public void run()
{
if (enumconnectionstate != enumconnectionstate1)
{
NetworkManager.this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture1.addListeners(futureListeners);
}
channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
});
}
}
示例2: dispatchPacket
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
* Will commit the packet to the channel. If the current thread 'owns' the channel it will write and flush the
* packet, otherwise it will add a task for the channel eventloop thread to do that.
*/
public void dispatchPacket(final Packet inPacket, final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
{
PacketSendEvent eventPre = new PacketSendEvent(State.PRE, inPacket);
eventPre.call();
if (eventPre.isCancelled()) return;
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(attrKeyConnectionState).get();
if (enumconnectionstate1 != enumconnectionstate)
{
logger.debug("Disabled auto read");
this.channel.config().setAutoRead(false);
}
if (this.channel.eventLoop().inEventLoop())
{
if (enumconnectionstate != enumconnectionstate1)
{
this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture.addListeners(futureListeners);
}
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
else
{
this.channel.eventLoop().execute(new Runnable()
{
public void run()
{
if (enumconnectionstate != enumconnectionstate1)
{
NetworkManager.this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture1.addListeners(futureListeners);
}
channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
});
}
PacketSendEvent eventPost = new PacketSendEvent(State.POST, inPacket);
eventPost.call();
}
示例3: dispatchPacket
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
* Will commit the packet to the channel. If the current thread 'owns' the channel it will write and flush the
* packet, otherwise it will add a task for the channel eventloop thread to do that.
*/
private void dispatchPacket(final Packet<?> inPacket, @Nullable final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
{
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).get();
if (enumconnectionstate1 != enumconnectionstate)
{
LOGGER.debug("Disabled auto read");
this.channel.config().setAutoRead(false);
}
if (this.channel.eventLoop().inEventLoop())
{
if (enumconnectionstate != enumconnectionstate1)
{
this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture.addListeners(futureListeners);
}
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
else
{
this.channel.eventLoop().execute(new Runnable()
{
public void run()
{
if (enumconnectionstate != enumconnectionstate1)
{
NetworkManager.this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture1.addListeners(futureListeners);
}
channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
});
}
}
示例4: dispatchPacket
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
* Will commit the packet to the channel. If the current thread 'owns' the channel it will write and flush the
* packet, otherwise it will add a task for the channel eventloop thread to do that.
*/
private void dispatchPacket(final Packet<?> inPacket, @Nullable final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
{
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).get();
if (enumconnectionstate1 != enumconnectionstate && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
{
LOGGER.debug("Disabled auto read");
this.channel.config().setAutoRead(false);
}
if (this.channel.eventLoop().inEventLoop())
{
if (enumconnectionstate != enumconnectionstate1 && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
{
this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture.addListeners(futureListeners);
}
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
else
{
this.channel.eventLoop().execute(new Runnable()
{
public void run()
{
if (enumconnectionstate != enumconnectionstate1 && !( inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket))
{
NetworkManager.this.setConnectionState(enumconnectionstate);
}
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
if (futureListeners != null)
{
channelfuture1.addListeners(futureListeners);
}
channelfuture1.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
});
}
}