Exemple #1
0
        public void TestLife(float deltaTime)
        {
            List <uint> list = new List <uint>();

            foreach (uint num in this.seqMessageCollection.Keys)
            {
                ApolloMessage message = this.seqMessageCollection[num];
                if (message != null)
                {
                    message.Life -= deltaTime;
                    if (message.Life <= 0f)
                    {
                        list.Add(num);
                        if (message.Handler != null)
                        {
                            TalkerEventArgs e = new TalkerEventArgs(ApolloResult.Timeout)
                            {
                                Context  = message.Context,
                                Response = null
                            };
                            message.Handler(message.Request, e);
                        }
                    }
                }
            }
            foreach (uint num2 in list)
            {
                this.seqMessageCollection.Remove(num2);
            }
        }
Exemple #2
0
        private bool popAndHandleApolloMessage()
        {
            if (this.apolloMessageCollections.Count == 0)
            {
                return(false);
            }
            ADebug.Log("popAndHandleApolloMessage: " + this.apolloMessageCollections.Count);
            ApolloMessage next = this.apolloMessageCollections.Next;

            if (next != null)
            {
                if (next.Handler != null)
                {
                    TalkerEventArgs e = new TalkerEventArgs(next.Response, next.Context);
                    next.Handler(next.Request, e);
                }
                if (next.HandlerWithoutReceipt != null)
                {
                    next.HandlerWithoutReceipt(next.Response);
                }
                if (next.HandlerWithReceipt != null)
                {
                    IPackable receipt = null;
                    next.HandlerWithReceipt(next.Response, ref receipt);
                    if (receipt != null)
                    {
                        ADebug.Log("HandlerWithReceipt receipt:" + receipt);
                        this.SendReceipt <NullResponse>(receipt, next.AsyncFlag);
                    }
                }
                if (next.IsRequest)
                {
                    ApolloMessageManager.Instance.RemoveMessage(next);
                }
            }
            return(true);
        }
        public void TestLife(float deltaTime)
        {
            List <uint> list = new List <uint>();

            using (Dictionary <uint, object> .KeyCollection.Enumerator enumerator = this.seqMessageCollection.Keys.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    uint          current       = enumerator.get_Current();
                    ApolloMessage apolloMessage = this.seqMessageCollection[current];
                    if (apolloMessage != null)
                    {
                        apolloMessage.Life -= deltaTime;
                        if (apolloMessage.Life <= 0f)
                        {
                            list.Add(current);
                            if (apolloMessage.Handler != null)
                            {
                                TalkerEventArgs talkerEventArgs = new TalkerEventArgs(ApolloResult.Timeout);
                                talkerEventArgs.Context  = apolloMessage.Context;
                                talkerEventArgs.Response = null;
                                apolloMessage.Handler(apolloMessage.Request, talkerEventArgs);
                            }
                        }
                    }
                }
            }
            using (List <uint> .Enumerator enumerator2 = list.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    uint current2 = enumerator2.get_Current();
                    this.seqMessageCollection.Remove(current2);
                }
            }
        }