当前位置: 首页>>代码示例>>Java>>正文


Java ChannelFuture.addListeners方法代码示例

本文整理汇总了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);
            }
        });
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:55,代码来源:NetworkManager.java

示例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();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:63,代码来源:NetworkManager.java

示例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);
            }
        });
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:55,代码来源:NetworkManager.java

示例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);
            }
        });
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:55,代码来源:NetworkManager.java


注:本文中的io.netty.channel.ChannelFuture.addListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。