Esempio n. 1
0
        public static void ReceiveMessage(Envelope envelope)
        {
            Logger.Info("Received message from communicator");

            if (envelope?.Message != null && envelope.Address != null)
            {
                Logger.Info($"Message from {envelope.Address.ToString()} to {envelope.ConvId}");

                if (ConversationDictionary.ContainsKey(envelope.ConvId))
                {
                    ConversationDictionary[envelope.ConvId].MessageInbox.Enqueue(envelope);
                }
                else
                {
                    Conversation newConversation = CreateNewConversation(envelope);
                    RegisterConversation(newConversation);

                    if (newConversation != null)
                    {
                        ConversationDictionary[envelope.ConvId].MessageInbox.Enqueue(envelope);
                        Logger.Info($"Started a new conversation as {envelope.ConvId}");
                        newConversation.Start();
                    }
                    else
                    {
                        Logger.Warn($"Unable to process message from {envelope.Address.ToString()}");
                    }
                }
            }
            else
            {
                Logger.Warn("Invalid message!");
            }
        }
Esempio n. 2
0
        public static void RegisterConversation(Conversation conversation)
        {
            conversation?.RegisterDistributedProcessCallbacks(Properties?.DistInstance);

            if (conversation != null && !ConversationDictionary.ContainsKey(conversation.Id))
            {
                ConversationDictionary[conversation.Id] = conversation;
            }
            else
            {
                Logger.Warn("Conversation already exists, cannot register it");
            }
        }