Ejemplo n.º 1
0
 private void Playing()
 {
     Receive <PlayMovieMessage>(
         message => Colorconsole.WriteLineRed(
             "Error: cannont start playing another movie before stopping existing one"));
     Receive <StopMovieMessage>(message => StopPlayingCurrentMovie());
 }
Ejemplo n.º 2
0
 private void StopPlayingCurrentMovie()
 {
     Colorconsole.WriteLineYellow($"user has stoped watching {_currentlyWatching}");
     _currentlyWatching = null;
     Become(Stopped);
     Colorconsole.WriteLineYellow("UserActore has become Stopped");
 }
Ejemplo n.º 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");
 }
Ejemplo n.º 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");
        }
Ejemplo n.º 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})");
     }
 }
Ejemplo n.º 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");
        }
Ejemplo n.º 7
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineGreen($"PlaybackActor PreReStart because: {reason}");
     base.PostRestart(reason);
 }
Ejemplo n.º 8
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineGreen("PlaybackActor PostStop");
 }
Ejemplo n.º 9
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineGreen("PlaybackActor PreStart");
 }
Ejemplo n.º 10
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineYellow($"UserActor PreReStart because: {reason}");
     base.PostRestart(reason);
 }
Ejemplo n.º 11
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineCyan("UserCoordinatorActor PreStart");
 }
Ejemplo n.º 12
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineMagenta($"PlaybackStatisticsActor PostRestart because: {reason}");
     base.PostRestart(reason);
 }
Ejemplo n.º 13
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineMagenta("PlaybackStatisticsActor PostStop");
 }
Ejemplo n.º 14
0
 protected override void PostRestart(Exception reason)
 {
     Colorconsole.WriteLineCyan($"UserCoordinatorActor PostRestart because: {reason}");
     base.PostRestart(reason);
 }
Ejemplo n.º 15
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineCyan("UserCoordinatorActor PostStop");
 }
Ejemplo n.º 16
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineMagenta("PlaybackStatisticsActor PreStart");
 }
Ejemplo n.º 17
0
 protected override void PreStart()
 {
     Colorconsole.WriteLineYellow("UserActor PreStart");
 }
Ejemplo n.º 18
0
 protected override void PreRestart(Exception reason, object message)
 {
     Colorconsole.WriteLineMagenta($"PlaybackStatisticsActor PreRestart because: {reason}");
     base.PreRestart(reason, message);
 }
Ejemplo n.º 19
0
 protected override void PostStop()
 {
     Colorconsole.WriteLineYellow("UserActor PostStop");
 }
Ejemplo n.º 20
0
 static void Main(string[] args)
 {
     Colorconsole.WriteLineGray("Creating MovieStreamingActorSystem");
     _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
     _movieStreamingActorSystem.AwaitTermination();
 }
Ejemplo n.º 21
0
        protected override void PreRestart(Exception reason, object message)
        {
            Colorconsole.WriteLineYellow($"UserActor PreRestart because: {reason}");

            base.PreRestart(reason, message);
        }