Esempio n. 1
0
        public bool RemoveTimer(TimerInstance handler)
        {
            if (handler != null && m_Handlers.ContainsKey(handler.Index))
            {
                m_Handlers.Remove(handler.Index);
                if (handler.IsValid())
                {
                    TimerTask task = m_Wheels[handler.WheelIndex].RemoveTask(handler);
                    handler.Clear();
                    if (task != null)
                    {
                        m_TaskPool.Release(task);
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
        protected void DoSend()
        {
            if (!IsConnected)
            {
                return;
            }

            lock (isSendingLocker)
            {
                if (isSending)
                {
                    return;
                }
            }

            byte[] sendBytes = null;
            lock (cachedWillSendMessageLocker)
            {
                if (cachedWillSendMessages.Count > 0)
                {
                    var willSendMessage = cachedWillSendMessages[0];
                    cachedWillSendMessages.RemoveAt(0);

                    sendBytes = Serialize(willSendMessage.ID, willSendMessage.CompressType, willSendMessage.CryptoType, willSendMessage.DataBytes);

                    willSendMessagePool.Release(willSendMessage);
                }
                else
                {
                    return;
                }
            }
            lock (isSendingLocker)
            {
                isSending = true;
            }

            if (sendAsyncEvent == null)
            {
                sendAsyncEvent            = new SocketAsyncEventArgs();
                sendAsyncEvent.Completed += OnHandleSocketEvent;
            }
            sendAsyncEvent.SetBuffer(sendBytes, 0, sendBytes.Length);
            if (NetSocket.SendAsync(sendAsyncEvent))
            {
                return;
            }

            OnSessionError(NetworkSessionError.DoSendFailedError);
        }
        public void DoUpdate(float deltaTime, float unscaleDeltaTime)
        {
            lock (m_MessageLocker)
            {
                foreach (var message in m_ReceivedMessages)
                {
                    if (message.Client != null && message.Client.Connected)
                    {
                        if (m_MessageHandlerDic.TryGetValue(message.ID, out var callback))
                        {
                            callback(message);
                        }
                        else
                        {
                        }
                    }

                    m_MessagePool.Release(message);
                }

                m_ReceivedMessages.Clear();
            }
        }
Esempio n. 4
0
 public static void ReleaseDispatcher(EventDispatcher dispatcher)
 {
     sm_DispatcherPool.Release(dispatcher);
 }
Esempio n. 5
0
 internal static void ReleaseNodeList(List <QuadNode> list)
 {
     sm_NodeListPool.Release(list);
 }
Esempio n. 6
0
 internal static void ReleaseObjectList(List <IQuadObject> list)
 {
     sm_ObjectListPool.Release(list);
 }