public static void LogAllActorPaths() { ColoredConsole.WriteTitle($"Logging all actors paths: "); ColoredConsole.WriteTitle($" MoviePlaybackActor: {ActorPaths.MoviePlaybackActor.Path}"); ColoredConsole.WriteTitle($" PlaybackStatisticsActor: {ActorPaths.PlaybackStatisticsActor.Path}"); ColoredConsole.WriteTitle($" MoviePlayCounterActor: {ActorPaths.MoviePlayCounterActor.Path}"); ColoredConsole.WriteTitle($" UserCoordinatorActor: {ActorPaths.UserCoordinatorActor.Path}"); string exampleUserId = "999"; ColoredConsole.WriteTitle($" UserActor({exampleUserId}): {ActorPaths.GetUserActorMetaData(exampleUserId).Path}"); }
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); }
public static Akka.Actor.IActorRef Create(int userId) { return(Context.ActorOf(UserActor.Props(userId), ActorPaths.GetUserActorMetaData(userId.ToString()).Name)); }