public static void StartActorSystem(bool createRootActor = false) { ActorSystemName = Constants.ActorSystemName; // Create an ActionSystem ColoredConsole.WriteTitle($"Creating '{ActorSystemName}' ActorSystem..."); // Create an Akka ActorSystem ActorSystemHelper.CreateActorSystem(ActorSystemName); if (createRootActor == true) { // Create first 'user' actor 'MoviePlaybackActor' in Akka ActorSystem _moviePlaybackActorRef = ActorSystemHelper.CreateActor(MoviePlaybackActor.Props(), ActorPaths.MoviePlaybackActor.Name); } }
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() { return(ActorSystemHelper.CreateActor(MoviePlaybackActor.Props(), ActorPaths.MoviePlaybackActor.Name)); }