private void HandleTryInitializeChat(Messages.TryInitializeChat x)
 {
     Dictionary<string, IActorRef> participantList = new Dictionary<string, IActorRef>();
         if(userAddresses.Keys.Contains(x.To))
             participantList.Add(x.To,userAddresses[x.To]);
      if(userAddresses.Keys.Contains(x.From))
             participantList.Add(x.To,userAddresses[x.From]);
     if(participantList.Count>1)
     {
         var chatServerActor = Context.ActorOf(Props.Create(() =>
               new ChatServerActor()));
         var addToChat = new ChatApp.Actors.Messages.AddToChat(participantList);
         chatServerActor.Tell(addToChat);
         Sender.Tell(new Messages.StartChat(chatServerActor));
     }
 }
Example #2
0
        private void HandleTryInitializeChat(Messages.TryInitializeChat x)
        {
            Dictionary <string, IActorRef> participantList = new Dictionary <string, IActorRef>();

            if (userAddresses.Keys.Contains(x.To))
            {
                participantList.Add(x.To, userAddresses[x.To]);
            }
            if (userAddresses.Keys.Contains(x.From))
            {
                participantList.Add(x.To, userAddresses[x.From]);
            }
            if (participantList.Count > 1)
            {
                var chatServerActor = Context.ActorOf(Props.Create(() =>
                                                                   new ChatServerActor()));
                var addToChat = new ChatApp.Actors.Messages.AddToChat(participantList);
                chatServerActor.Tell(addToChat);
                Sender.Tell(new Messages.StartChat(chatServerActor));
            }
        }