示例#1
0
        public void Run()
        {
            Envelope     envelope;
            Conversation conversation;

            while (stillRunning)
            {
                envelope = UdpCommunicator.Receive(1000);
                if (envelope == null && TcpCommunicator != null)
                {
                    envelope = TcpCommunicator.Receive(1000);
                }

                if (envelope != null)
                {
                    ConversationId id = envelope.Message.ConversationId;
                    conversation = Conversations.GetConversation(id);

                    if (conversation != null) // If the conversation already exists
                    {
                        conversation.IncomingEnvelopes.Enqueue(envelope);
                    }
                    else // If the conversation does not exist
                    {
                        Responder newConversation;
                        newConversation = _conversationFactory.CreateFromEnvelope(envelope);
                        Message m = envelope.Message;
                        newConversation.Launch(m);
                        Conversations.Add(newConversation);
                    }
                }
            }
        }
示例#2
0
        public Conversation GetConversation(ConversationId conversationId)
        {
            Conversation conversation;

            _activeConversation.TryGetValue(conversationId.ToString(), out conversation);

            return(conversation);
        }
示例#3
0
        protected override bool Initialize()
        {
            if (!base.Initialize())
            {
                return(false);
            }

            ConvId = IncomingEnvelope?.Message?.ConversationId;
            if (ConvId != null)
            {
                RemoteEndPoint = IncomingEnvelope?.EndPoint;
                //State = PossibleState.Working;
            }
            else
            {
                Error = $"Cannot initialize {GetType().Name} conversation because ConvId in incoming message is null";
            }

            return(Error == null);
        }
示例#4
0
        public void Remove(ConversationId conversationId)
        {
            Conversation conversation;

            _activeConversation.TryRemove(conversationId.ToString(), out conversation);
        }