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); } } } }
public Conversation GetConversation(ConversationId conversationId) { Conversation conversation; _activeConversation.TryGetValue(conversationId.ToString(), out conversation); return(conversation); }
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); }
public void Remove(ConversationId conversationId) { Conversation conversation; _activeConversation.TryRemove(conversationId.ToString(), out conversation); }