Beispiel #1
0
 private void Playing()
 {
     Receive <PlayMovieMessage>(
         message => Colorconsole.WriteLineRed(
             "Error: cannont start playing another movie before stopping existing one"));
     Receive <StopMovieMessage>(message => StopPlayingCurrentMovie());
 }
Beispiel #2
0
 private void StopPlayingCurrentMovie()
 {
     Colorconsole.WriteLineYellow($"user has stoped watching {_currentlyWatching}");
     _currentlyWatching = null;
     Become(Stopped);
     Colorconsole.WriteLineYellow("UserActore has become Stopped");
 }
Beispiel #3
0
 private void StartPlayingMovie(string movieTitle)
 {
     _currentlyWatching = movieTitle;
     Colorconsole.WriteLineYellow($"UserActor {_userId } is currently watching {_currentlyWatching}");
     Context.ActorSelection("/user/Playback/PlaybackStatistics/MoviePlayCounter").Tell(new IncrementPlayCountMessage(movieTitle));
     Become(Playing);
     Colorconsole.WriteLineCyan("UserActor has now become Playing");
 }
Beispiel #4
0
        private void Stopped()
        {
            Receive <PlayMovieMessage>(message => StartPlayingMovie(message.MovieTitle));
            Receive <StopMovieMessage>(
                message => Colorconsole.WriteLineRed("Error: cannot stop if nothing is playing"));

            Colorconsole.WriteLineYellow("UserActor has now become Stopped");
        }
Beispiel #5
0
 private void CreateChildUserIfNotExist(int userId)
 {
     if (!_users.ContainsKey(userId))
     {
         IActorRef newChildActorRef =
             Context.ActorOf(Props.Create(() => new UserActor(userId)), "User" + userId);
         _users.Add(userId, newChildActorRef);
         Colorconsole.WriteLineCyan($"UserCoordinatorActor created new child UserActor for {userId} (Total User: {_users.Count})");
     }
 }
Beispiel #6
0
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle] += 1;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            // Simulated Bugs
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }
            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException();
            }
            Colorconsole.WriteLineMagenta($"MoviePlayCounterActor {message.MovieTitle} has been watched {_moviePlayCounts[message.MovieTitle]} times");
        }
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineGreen($"PlaybackActor PreReStart because: {reason}");
     base.PostRestart(reason);
 }
 protected override void PostStop()
 {
     Colorconsole.WriteLineGreen("PlaybackActor PostStop");
 }
 protected override void PreStart()
 {
     Colorconsole.WriteLineGreen("PlaybackActor PreStart");
 }
Beispiel #10
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineYellow($"UserActor PreReStart because: {reason}");
     base.PostRestart(reason);
 }
Beispiel #11
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineCyan("UserCoordinatorActor PreStart");
 }
Beispiel #12
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineMagenta($"PlaybackStatisticsActor PostRestart because: {reason}");
     base.PostRestart(reason);
 }
Beispiel #13
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineMagenta("PlaybackStatisticsActor PostStop");
 }
Beispiel #14
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineCyan($"UserCoordinatorActor PostRestart because: {reason}");
     base.PostRestart(reason);
 }
Beispiel #15
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineCyan("UserCoordinatorActor PostStop");
 }
Beispiel #16
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineMagenta("PlaybackStatisticsActor PreStart");
 }
Beispiel #17
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineYellow("UserActor PreStart");
 }
Beispiel #18
0
 protected override void PreRestart(Exception reason, object message)
 {
     Colorconsole.WriteLineMagenta($"PlaybackStatisticsActor PreRestart because: {reason}");
     base.PreRestart(reason, message);
 }
Beispiel #19
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineYellow("UserActor PostStop");
 }
Beispiel #20
0
 static void Main(string[] args)
 {
     Colorconsole.WriteLineGray("Creating MovieStreamingActorSystem");
     _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
     _movieStreamingActorSystem.AwaitTermination();
 }
Beispiel #21
0
        protected override void PreRestart(Exception reason, object message)
        {
            Colorconsole.WriteLineYellow($"UserActor PreRestart because: {reason}");

            base.PreRestart(reason, message);
        }