示例#1
0
 public static Props Props(
     IActorRef scriptRepository
     , ICompetitionInfo competitionInfo
     , IActorRef lobby
     , ICompetitorFactory factory
     , IActorRef resultRepository)
 {
     return(Akka.Actor.Props.Create(() => new Competition(scriptRepository, competitionInfo, lobby, factory, resultRepository)));
 }
示例#2
0
        public CompetitorLobby(
            ISelectableSet <IActorRef> competitors
            , ICompetitionInfo lobbyConfiguration)
        {
            Receive <RequestLobbyJoin>(obj =>
            {
                if (competitors.Contains(Sender))
                {
                    return;
                }

                competitors.Add(Sender);

                Context.WatchWith(
                    Sender
                    , new CompetitorTerminated(Sender));
            });

            Receive <RequestLobbyQuit>(obj =>
            {
                Context.Unwatch(Sender);
                competitors.Remove(Sender);
            });

            Receive <OrderCompetitorsSelection>(msg =>
            {
                try
                {
                    Sender.Tell(competitors.Select(lobbyConfiguration.PlayerCount).ToList());
                }
                catch (NotEnoughPlayersException e)
                {
                    Sender.Tell(NotEnoughPlayers.Instance);
                }
            });

            Receive <OrderAgents>(obj =>
            {
                var orderProps = LobbyOrder.Props(Sender, Self);
                Context.ActorOf(orderProps);
            });

            Receive <CompetitorTerminated>(obj => { competitors.Remove(obj.ActorRef); });
        }
示例#3
0
        public Competition(
            IActorRef scriptRepository
            , ICompetitionInfo competitionInfo
            , IActorRef lobby
            , ICompetitorFactory competitorFactory
            , IActorRef resultsRepository)
        {
            _scriptRepository  = scriptRepository;
            _competitionInfo   = competitionInfo;
            _lobby             = lobby;
            _competitorFactory = competitorFactory;
            _resultsRepository = resultsRepository;

            EnsureSubscription(_scriptRepository);

            Receive <IEnumerable <Script> >(OnScriptBatchReceived);
            Receive <Data.Entities.Messages.AddedEvent <Script> >(OnNewScriptAdded);
            Receive <Data.Entities.Messages.UpdatedEvent <Script> >(OnScriptUpdated);
            Receive <Data.Entities.Messages.DeletedEvent <Script> >(OnScriptDeleted);
        }
示例#4
0
 public AddCompetition(IActorRef lobby, ICompetitionInfo competitionInfo)
 {
     Lobby = lobby;
     Info  = competitionInfo;
 }
 public CompetitionRegistration(ICompetitionInfo configuration, ICompetitionActorPropsFactory factory)
 {
     Info    = configuration;
     Factory = factory;
 }
示例#6
0
 public static Props Props(ISelectableSet <IActorRef> playerSet, ICompetitionInfo lobbyConfiguration)
 {
     return(Akka.Actor.Props.Create(() => new CompetitorLobby(playerSet, lobbyConfiguration)));
 }