Esempio n. 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}'.");
        }
        public PlaybackStatisticsActor()
            : base()
        {
            ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");

            _moviePlayCounterActor = Context.ActorOf(MoviePlayCounterActor.Props(), ActorPaths.MoviePlayCounterActor.Name);
        }
Esempio n. 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}'.");
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 6
0
        public static IActorRef CreateActorHelper(Props props, string actorName)
        {
            IActorRef actorRef = GetAkkaActorSystem().ActorOf(props, actorName);

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

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

            // Initial behavior
            Become(StoppedBehavior);
        }
Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 11
0
 public MoviePlayCounterActor()
     : base()
 {
     ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");
     _moviePlayCount = new Dictionary <string, int>();
 }
Esempio n. 12
0
 public UserCoordinatorActor()
     : base()
 {
     ColoredConsole.WriteCreationEvent($"  [{this.ActorName}] '{ActorName}' actor constructor.");
 }