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


C# NetState.Dispose方法代码示例

本文整理汇总了C#中NetState.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NetState.Dispose方法的具体用法?C# NetState.Dispose怎么用?C# NetState.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetState的用法示例。


在下文中一共展示了NetState.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunTaskNetStateConnect

        void RunTaskNetStateConnect(NetState netState)
        {
            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateConnect;
            if (tempEV != null)
            {
                var arg = new NetStateConnectEventArgs
                {
                    NetState = netState,
                    AllowConnect = true
                };
                tempEV(this, arg);
                if (arg.AllowConnect == false)
                {
                    netState.Dispose();
                    return;
                }
            }
            netState.Serial = netStateId++;

            m_netStateManager.InternalAddNetState(netState.Serial, netState);
            netState.Start();
        }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:24,代码来源:WorldBase.cs

示例2: OnReceive

        public bool OnReceive(NetState ns)
        {
            ByteQueue buffer = ns.Buffer;

            if (buffer == null || buffer.Length <= 0)
                return true;

            lock (buffer)
            {
                int length = buffer.Length;

                while (length > 0)
                {
                    int packetID = buffer.GetPacketID();

                    PacketHandler handler = ns.GetHandler(packetID);

                    if (handler == null)
                    {
                        byte[] data = new byte[length];
                        length = buffer.Dequeue(data, 0, length);

                        new PacketReader(data, length, false).Trace(ns);

                        break;
                    }

                    int packetLength = handler.Length;

                    if (packetLength <= 0)
                    {
                        if (length >= 3)
                        {
                            packetLength = buffer.GetPacketLength();

                            if (packetLength < 3)
                            {
                                ns.Dispose();
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (length < packetLength)
                        break;

                    byte[] packetBuffer = BufferSize >= packetLength ? _buffers.AcquireBuffer() : new byte[packetLength];
                    packetLength = buffer.Dequeue(packetBuffer, 0, packetLength);

                    PacketReader r = new PacketReader(packetBuffer, packetLength, handler.Length != 0);

                    handler.OnReceive(ns, r);

                    length = buffer.Length;

                    if (BufferSize >= packetLength)
                        _buffers.ReleaseBuffer(packetBuffer);
                }
            }

            return true;
        }
开发者ID:nydehi,项目名称:openuo,代码行数:66,代码来源:MessagePump.cs

示例3: RunTaskNetStateDisconnect

        private void RunTaskNetStateDisconnect(NetState netState)
        {
            m_netStateManager.InternalRemoveNetState(netState.Serial);

            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateDisconnect;
            if (tempEV != null)
            {
                var arg = new NetStateDisconnectEventArgs
                {
                    NetState = netState,
                };
                tempEV(this, arg);
            }

            netState.ExitWorld();
            netState.Dispose();
        }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:19,代码来源:WorldBase.cs

示例4: WorldServerExit

 /// <summary>
 /// 
 /// </summary>
 /// <param name="netState"></param>
 /// <param name="packetReader"></param>
 internal static void WorldServerExit( NetState netState, PacketReader packetReader )
 {
     netState.Send( new ExitAck( 3 ) );
     netState.Dispose( true, 3 );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:10,代码来源:WorldPacketHandlers.cs


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