Exemple #1
0
        public T CreateFromMessage <T>(byte[] bytes, IPEndPoint refEp,
                                       Conversation.ActionHandler preAction, Conversation.ActionHandler postAction,
                                       Conversation.ActionHandler failAction) where T : Conversation, new()
        {
            bool              initiator = false;
            MessageId         ConvId    = Message.Decode <Message>(bytes).ConvId;
            ConversationQueue queue     = ConversationDictionary.Instance.CreateQueue(ConvId);

            queue.Enqueue(bytes);

            T conversation = new T()
            {
                InitiatorConv     = initiator,
                ConvId            = ConvId,
                Timeout           = DefaultTimeout,
                MaxRetries        = DefaultMaxRetries,
                Done              = false,
                EndIP             = refEp,
                MyQueue           = queue,
                PreExecuteAction  = preAction,
                PostExecuteAction = postAction,
                FailureAction     = failAction
            };


            return(conversation);
        }
        private void EnqueueMessage(byte[] bytes)
        {
            Message           msg   = Message.Decode <Message>(bytes);
            ConversationQueue queue = ConversationDictionary.Instance.Lookup(msg.ConvId);

            if (queue != null)
            {
                queue.Enqueue(bytes);
            }
        }
        public void EnqueueAndDequeue_1Envelope()
        {
            MessageId         msgId  = new MessageId();
            MessageId         convId = new MessageId();
            ConversationQueue q      = new ConversationQueue();
            ExitGame          msg1   = new ExitGame()
            {
                MsgId = msgId, ConvId = convId, PlayerID = 1, GameID = 1
            };

            q.Enqueue(msg1.Encode());
            byte[] result = q.Dequeue(1);
            Assert.AreEqual(msg1.Encode(), result);
        }
        public void SetupConversation()
        {
            MessageId msgid = new MessageId()
            {
                Pid = 1, Seq = 1
            };
            Message msg = new Message()
            {
                MsgId  = msgid,
                ConvId = msgid
            };
            ConversationQueue queue = ConversationDictionary.Instance.SetupConversation(msgid, msg.Encode());

            Assert.AreEqual(queue.QueueID, msgid);
        }
Exemple #5
0
        public T CreateFromConversationType <T>(IPEndPoint receiver,
                                                Conversation.ActionHandler preAction, Conversation.ActionHandler postAction,
                                                Conversation.ActionHandler failAction) where T : Conversation, new()
        {
            bool              initiator = true;
            MessageId         ConvId    = MessageId.Create();
            ConversationQueue queue     = ConversationDictionary.Instance.CreateQueue(ConvId);

            T conversation = new T()
            {
                ConvId            = ConvId,
                Timeout           = DefaultTimeout,
                MaxRetries        = DefaultMaxRetries,
                Done              = false,
                InitiatorConv     = initiator,
                EndIP             = receiver,
                MyQueue           = queue,
                PreExecuteAction  = preAction,
                PostExecuteAction = postAction,
                FailureAction     = failAction
            };

            return(conversation);
        }
 public ConversationQueueManager(ConversationQueueFactory conversationQueueFactory)
 {
     _conversationQueue = conversationQueueFactory.Create();
 }
Exemple #7
0
 public bool Contains(User obj)
 {
     return(ConversationQueue.Any(x => x.Id == obj.Id));
 }