예제 #1
0
        public CustomUntypedActor()
        {
            var actorName = Self.Path.Name;

            // ColoredConsole.WriteCreationEvent($"  [{actorName}] CREATING '{actorName}' actor with address '{Self.Path.ToString()}'.");
            ColoredConsole.WriteCreationEvent($"  [{actorName}] Path: '{Self.Path.ToString()}', UID: '{Self.Path.Uid}', Address: '{Self.Path.Address}', Parent: '{Self.Path.Parent}', Root: '{Self.Path.Root}'.");
        }
예제 #2
0
        public PlaybackStatisticsActor()
            : base()
        {
            ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");

            _moviePlayCounterActor = Context.ActorOf(MoviePlayCounterActor.Props(), ActorPaths.MoviePlayCounterActor.Name);
        }
예제 #3
0
        public CustomReceiveActor()
        {
            _actorName = Self.Path.Name;

            // ColoredConsole.WriteCreationEvent($"  [{_actorName}] CREATED '{_actorName}' actor with address '{Self.Path.ToString()}'.");
            ColoredConsole.WriteCreationEvent($"  [{_actorName}] Name: '{Self.Path.Name}', '{Self.Path.Uid}', '{Self.Path.Address}', '{Self.Path.Parent}', '{Self.Path.Root}'.");
        }
예제 #4
0
        public MoviePlaybackActor()
            : base()
        {
            ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");

            UserCoordinatorActorRef    = ActorSystemHelper.CreateActorHelper(Context, UserCoordinatorActor.Props(), ActorPaths.UserCoordinatorActor.Name);
            PlaybackStatisticsActorRef = ActorSystemHelper.CreateActorHelper(Context, PlaybackStatisticsActor.Props(), ActorPaths.PlaybackStatisticsActor.Name);
        }
예제 #5
0
        public static IActorRef CreateActorHelper(IUntypedActorContext context, Props props, string actorName)
        {
            IActorRef actorRef = context.ActorOf(props, actorName);

            ColoredConsole.WriteCreationEvent($"CREATED '{actorName}' actor.");

            return(actorRef);
        }
예제 #6
0
        public static IActorRef CreateActorHelper(Props props, string actorName)
        {
            IActorRef actorRef = GetAkkaActorSystem().ActorOf(props, actorName);

            ColoredConsole.WriteCreationEvent($"CREATED '{actorName}' actor.");

            return(actorRef);
        }
예제 #7
0
        public UserActor(int userId)
        {
            ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");
            _userId           = userId;
            _currentlyPlaying = null;

            // Initial behavior
            Become(StoppedBehavior);
        }
예제 #8
0
        public static void TerminateActorSystem()
        {
            // Notify ActorSystem (and all child actors) to temrinate
            ColoredConsole.WriteCreationEvent($"TERMINATING '{GetAkkaActorSystem().Name}' ActorSystem.");
            AkkaActorSystem.Terminate();

            // Wait for ActorSystem to finish shutting down
            Task whenTerminatedTask = AkkaActorSystem.WhenTerminated;

            whenTerminatedTask.Wait();

            AkkaActorSystem = null;
        }
예제 #9
0
        public static void CreateActorSystem(string actorSystemName)
        {
            // Read Akka configuration and create an ActionSystem
            Config config = HoconConfiguration.ReadAndParse(Constants.AkkaConfigurationFileName);

            ColoredConsole.WriteTitle($"Application Name: {config.GetString("application.info.name")}");

            if (AkkaActorSystem == null)
            {
                AkkaActorSystem = ActorSystem.Create(actorSystemName, config);
                ColoredConsole.WriteCreationEvent($"CREATED '{actorSystemName}' ActorSystem.");
            }

            var petabridgeCmdHost = PetabridgeCmd.Get(GetAkkaActorSystem());

            petabridgeCmdHost.RegisterCommandPalette(Petabridge.Cmd.Remote.RemoteCommands.Instance);
            petabridgeCmdHost.Start();
        }
예제 #10
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);
        }
예제 #11
0
 public MoviePlayCounterActor()
     : base()
 {
     ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");
     _moviePlayCount = new Dictionary <string, int>();
 }
예제 #12
0
 public UserCoordinatorActor()
     : base()
 {
     ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");
 }