Example #1
0
        private IActorRef CreateOrGetChildActor(int userId)
        {
            IActorRef actorRef;

            var childActorMetaData = ActorPaths.GetUserActorMetaData(userId.ToString());

            // ColoredConsole.WriteTemporaryDebugMessage($"User Actor Path: '{userActorMetaData.Path}'");

            // Use ResolveOne or Identity message to get the Actor Reference
            // actorRef = _actorSystemHelper.GetActorRefUsingIdentity(userActorMetaData.Path);
            actorRef = ActorSystemHelper.GetActorRefUsingResolveOne(childActorMetaData.Path);
            if (actorRef == null)
            {
                actorRef = ActorSystemHelper.CreateActor(Context, UserActor.Props(userId), childActorMetaData.Name);
                ColoredConsole.WriteCreationEvent($"    [{this.ActorName}] '{this.ActorName}' has created new child '{childActorMetaData.Name}' actor for UserId {userId}.");
            }

            return(actorRef);
        }
Example #2
0
 public static Akka.Actor.IActorRef Create(int userId)
 {
     return(Context.ActorOf(UserActor.Props(userId), ActorPaths.GetUserActorMetaData(userId.ToString()).Name));
 }