Class ActorSelection.
Наследование: ICanTell
        public PlayerSupervisor(ActorSelection eventWriter)
        {
            _eventWriter = eventWriter;
            Receive<BatterEventMessage>(msg =>
            {
                _eventWriter.Tell(msg);
                var playerActor = Context.Child("batter-" + msg.PlayerId);
                if (playerActor == ActorRefs.Nobody)
                {
                    playerActor = Context.ActorOf(BatterActor.Create(msg.PlayerId), "batter-" + msg.PlayerId);
                }

                playerActor.Tell(msg);
            });

            Receive<EndOfFeed>(msg =>
            {
                _eventWriter.Tell(msg);
                var playerActors = Context.GetChildren();
                foreach (var playerActor in playerActors)
                {
                    playerActor.Tell(msg);
                }
            });
        }
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     system = ActorSystem.Create("MyClientSystem");
     serverActor = system.ActorSelection("akka.tcp://TestServer@localhost:8081/user/MyServerActor");
     uiActor = system.ActorOf(Props.Create(() => new UIActor(this.textBox)), "MyClient");
     clientActor = system.ActorOf(Props.Create(() => new ClientActor(serverActor, uiActor)), Guid.NewGuid().ToString());
 }
Пример #3
0
 private IActorRef CreatePerformanceCounterActor(string metricName, ActorSelection metricCollector,
     Func<PerformanceCounter> performanceCounterGenerator, int collectorIntervalMs)
 {
     return _monitorActorSystem.ActorOf(
         Props.Create(() => new PerformanceCounterActor(metricName, metricCollector,
             performanceCounterGenerator, collectorIntervalMs)),
         metricName.ToLowerInvariant() + "Counter");
 }
Пример #4
0
 private void _init()
 {
     _log.Debug("初始化监听sina的作业");
     actorSystem = ActorSystem.Create(ConstantsHelper.AKKA_PATH_SERVER);
     // var path = String.Format("akka.tcp://{2}@localhost:8091/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation", ConstantsHelper.AKKA_PATH_SERVER);
     var path = String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation");
     sinaActor = actorSystem.ActorSelection(path);
 }
Пример #5
0
        public MetricDisplayActor(DataTable metricTable, DataGridView dataGridView)
        {
            _dataGridView = dataGridView;
            _metricTable = metricTable;
            Receive<Metric>(m => HandleMetric(m));

            string monitorServer = ConfigurationManager.AppSettings["MonitorServer"];
            string metricCollectorPath = string.Format("akka.tcp://WinSrvMonitorServer@{0}:8041/user/metricDistributer", monitorServer);
            _metricCollector = Program.MonitorActorSystem.ActorSelection(metricCollectorPath);
            _metricCollector.Tell(new SubscribeToMetrics(Self));
        }
        public PerformanceCounterActor(string metricName, ActorSelection metricCollector,
            Func<PerformanceCounter> performanceCounterGenerator, int collectIntervalMs)
        {
            _serverName = System.Net.Dns.GetHostName();
            _metricName = metricName;
            _collectIntervalMs = collectIntervalMs;
            _metricCollector = metricCollector;

            _performanceCounterGenerator = performanceCounterGenerator;
            _cancelPublishing = new Cancelable(Context.System.Scheduler);

            Receive<GatherMetrics>(gm => HandleGatherMetrics(gm));
        }
Пример #7
0
        public async Task<DirectoryInfo> GetRootDirectory(ActorSelection actor)
        {
            var answer = await actor.Ask(new RootDirectoryActor.GetRootDirectory());

            if (answer is RootDirectoryActor.GetRootDirectoryResult)
            {
                var result = answer as RootDirectoryActor.GetRootDirectoryResult;

                return result.Success ? result.CurrentRootDirectory : null;
            }

            LogFailure(answer);

            return null;
        }
Пример #8
0
 private void _start()
 {
     if (strategy.TradeMode == TradeMode.BACK_TEST)
     {
         // 获取历史行情
         _market = Context.ActorSelection("akka.tcp://myServer@localhost:8081/securities/market/history");
     }
     else
     {
         // 
         _market = Context.ActorSelection("akka.tcp://myServer@localhost:8081/securities/market");
     }
     _watchStock();
     strategy.Start();
 }
Пример #9
0
        private static int TransmitMessageManyTimes(int counter, ActorSelection start, int amount)
        {
            Console.Write($"Transmitting {amount:##,###} message(s) -> ");
            for (int i = 0; i < amount; i++)
            {
                counter++;

                //start.Tell(new AuditMessage("Message no. - " + counter.ToString()));
                start.Ask(new AuditMessage("Message no. - " + counter.ToString())).ContinueWith((m) =>
                {

                });
            }
            Console.WriteLine(" [x] <- Transmitted message(s)");
            return counter;
        }
        public ChatClientCoordinatorActor()
        {
            //get a reference to the remote actor
            _chatCoordinatorActor = ClientActorSystemContainer.Instance.System.ActorSelection("akka.tcp://ChatServer@localhost:8080/user/ChatApp");
            _consoleReaderActor = ClientActorSystemContainer.Instance.System.ActorOf(Props.Create(() => new ConsoleReaderActor()));
            _consoleWriterActor = ClientActorSystemContainer.Instance.System.ActorOf(Props.Create(() => new ConsoleWriterActor()));

            Receive<Messages.Ok>(x => HandleOK(x));
            Receive<Messages.StartChat>(x => HandleStartChat(x));

            Receive<Messages.TryInitializeChat>(x => HandleTryInitializeChat(x));
            Receive<Messages.ConsoleCommand>(x => HandleConsoleCommand(x));

            _chatCoordinatorActor.Tell(new ChatApp.Actors.Messages.ChangeState(UserState.Online, userName));
            _consoleReaderActor.Tell("Start");
        }
Пример #11
0
 private IActorRef Identify(ActorSelection selection)
 {
     var idProbe = CreateTestProbe();
     selection.Tell(new Identify(selection), idProbe.Ref);
     var result = idProbe.ExpectMsg<ActorIdentity>().Subject;
     var asked = selection.Ask<ActorIdentity>(new Identify(selection)).Result;
     asked.Subject.ShouldBe(result);
     asked.MessageId.ShouldBe(selection);
     IActorRef resolved;
     try
     {
         resolved = selection.ResolveOne(TimeSpan.FromSeconds(3)).Result;
     }
     catch
     {
         resolved = null;
     }
     resolved.ShouldBe(result);
     return result;
 }
Пример #12
0
        public DBClientActor(IUnityContainer container, IEventAggregator eventAggregator)
        {
            _container = container;
            _dbRootActor = Context.System.ActorSelection("akka.tcp://WebDB@localhost:8081/user/DBEntityRoot");
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent<WebDB.Client.Prism.Core.SearchEvent>()
                .Subscribe(HandleSearchEvent);
            _eventAggregator.GetEvent<EntityUpdatedEvent>().Subscribe(SendEntityUpdateToSystem);

            Context.System.Scheduler.ScheduleTellRepeatedly(0, 100, Self, new TickMessage(), Self);

            Receive<TickMessage>(message => HandleTick());
            Receive<Tuple<string, string>>((message) => HandleDoSearch(message.Item1, message.Item2));
            Receive<AkkaSearchResults>(message => HandleSearchResult(message));
            Receive<AkkaGetEntityTypesResponse>(message => HandleEntityTypesResponse(message));
            Receive<GetEntityTypes>(message => GetEntityTypesFromSystem());
            Receive<NotifySubscribersOfEntityChange>(message => HandleNotifySubscribersOfEntityChanged(message));

            GetEntityTypesFromSystem();
            _self = Self;
        }
Пример #13
0
        static void Main(string[] args)
        {
            _system = ActorSystem.Create("AdService");
            CreateKeywords();
            CreateSpaces();
            CreateAds();
            _system.ActorOf<WebQueryProcessActor>("RequestListener");


            _adsPerSecondStatisticsActor = _system.ActorOf<AdsPerSecondCounter>();

            System.Threading.Thread.Sleep(1000); // Wait for system to initialize.
            //Console.WriteLine("Press [Enter] to start.");
            Console.ReadLine();

            for (int i = 0; i < IMPRESSIONS; i++)
            {
                GetBestAdForSpace("JasonsBanner", i);
                GetBestAdForSpace("JasonsSide", i);
                GetBestAdForSpace("SomeonesMobileApp", i);
                GetBestAdForSpace("DogGameBanner", i);
                //System.Threading.Thread.Sleep(1);
            }
        
            //while (_countComplete < IMPRESSIONS * 3)
            //    System.Threading.Thread.Sleep(1);

            Console.WriteLine("Done\nPress [Enter] for stats.");
            Console.ReadLine();

            foreach (var adActor in _allAdActors)
                adActor.Tell(new PrintStats());

            ActorSelection allImpressions = new ActorSelection(_spacesRoot, "*/*"); // This isn't sending right now.
            allImpressions.Tell(new PrintStats());

            Console.ReadLine();
        }
Пример #14
0
 /// <inheritdoc/>
 protected bool Equals(ActorSelection other)
 {
     return(Equals(Anchor, other.Anchor) && Equals(PathString, other.PathString));
 }
Пример #15
0
 /// <summary>
 /// INTERNAL API
 /// 
 /// Convenience method used by remoting when receiving <see cref="ActorSelectionMessage"/> from a remote
 /// actor.
 /// </summary>
 internal static void DeliverSelection(InternalActorRef anchor, ActorRef sender, ActorSelectionMessage sel)
 {
     var actorSelection = new ActorSelection(anchor, sel.Elements);
     actorSelection.Tell(sel.Message, sender);
 }
Пример #16
0
 public void SetRootDirectory(ActorSelection actor, DirectoryInfo directory)
 {
     actor.Tell(new RootDirectoryActor.SetRootDirectory(directory));
 }
Пример #17
0
 public void SetRootDirectoryFromCommandLineArgumentsIfExists(ActorSelection actorSelection)
 {
     actorSelection.Tell(new RootDirectoryActor.SetRootDirectoryFromCommandLineArgumentsIfExists());
 }
 protected override void PreStart()
 {
     _roomSupervisor = Context.ActorSelection(string.Format("akka.tcp://ChatServer@{0}:{1}/user/roomSupervisor", _serverIp, _serverPort));
     base.PreStart();
 }
Пример #19
0
 public GeneralController()
 {
     _dbEntityRoot = WebApiApplication.System.ActorSelection("akka://WebDB/user/DBEntityRoot");
 }
Пример #20
0
 /// <summary>
 ///		Called when the actor is being started.
 /// </summary>
 protected override void PreStart()
 {
     _taskController = Context.ActorSelection("../..");
 }
Пример #21
0
 static FrontActorSystem()
 {
     System = ActorSystem.Create("TaxiSystem");
     SignalRActor = System.ActorOf(Props.Create(() => new PresentingActor()));
     Presenter = System.ActorSelection("akka.tcp://TaxiBackend@localhost:8080/user/presenter");
 }
 public static Props Create(ActorSelection eventWriter)
 {
     return Props.Create(() => new PlayerSupervisor(eventWriter));
 }
Пример #23
0
 public ActorSelectionRoutee(ActorSelection actor)
 {
     this.actor = actor;
 }
Пример #24
0
 public ActorSelectionRoutee(ActorSelection actor)
 {
     _actor = actor;
 }
Пример #25
0
 /// <summary>
 /// Create a new instance with one more routee and the same <see cref="RoutingLogic"/>.
 /// </summary>  
 public Router AddRoutee(ActorSelection routee)
 {
    return AddRoutee(new ActorSelectionRoutee(routee));
 }
Пример #26
0
        /// <summary>
        /// INTERNAL API
        ///
        /// Convenience method used by remoting when receiving <see cref="ActorSelectionMessage"/> from a remote
        /// actor.
        /// </summary>
        internal static void DeliverSelection(InternalActorRef anchor, ActorRef sender, ActorSelectionMessage sel)
        {
            var actorSelection = new ActorSelection(anchor, sel.Elements);

            actorSelection.Tell(sel.Message, sender);
        }
Пример #27
0
 protected bool Equals(ActorSelection other)
 {
     return(Equals(Anchor, other.Anchor) && Equals(Elements, other.Elements));
 }
Пример #28
0
 /// <summary>
 /// Send the message created with <paramref name="deliveryMessageMapper" /> function to the
 /// <paramref name="destination" /> actor. It will retry sending the message until the delivery is
 /// confirmed with <see cref="ConfirmDelivery" />.
 /// Correlation between these two methods is performed by deliveryId that is provided as parameter
 /// to the <paramref name="deliveryMessageMapper"/> function. The deliveryId is typically passed in the message to
 /// the destination, which replies with a message containing the same 'deliveryId'.
 /// 
 /// The 'deliveryId' is a strictly monotonically increasing sequence number without gaps.
 /// The same sequence is used for all destinations of the actor, i.e. when sending
 /// to multiple destinations the destinations will see gaps in the sequence if no translation is performed.
 /// 
 /// During recovery this method will not send out the message, but it will be sent later if no matching 
 /// <see cref="ConfirmDelivery" /> was performed.
 /// </summary>
 /// <exception cref="MaxUnconfirmedMessagesExceededException">
 /// Thrown when <see cref="UnconfirmedCount" /> is greater than or equal to <see cref="MaxUnconfirmedMessages" />.
 /// </exception>
 public void Deliver(ActorSelection destination, Func<long, object> deliveryMessageMapper)
 {
     var isWildcardSelection = destination.PathString.Contains("*");
     if (isWildcardSelection)
         throw new NotSupportedException(
             "Delivering to wildcard actor selections is not supported by AtLeastOnceDelivery. " +
             "Introduce an mediator Actor which this AtLeastOnceDelivery Actor will deliver the messages to," +
             "and will handle the logic of fan-out and collecting individual confirmations, until it can signal confirmation back to this Actor.");
     Deliver(ActorPath.Parse(destination.PathString), deliveryMessageMapper);
 }
Пример #29
0
 public ActorSelectionAdapter(ActorSelection actorSelection)
 {
     if (actorSelection == null) throw new ArgumentNullException(nameof(actorSelection));
     _actorSelection = actorSelection;
 }
Пример #30
0
 /// <summary>
 /// Create a new instance without the specified routee.
 /// </summary>
 public Router RemoveRoutee(ActorSelection routee)
 {
     return RemoveRoutee(new ActorSelectionRoutee(routee));
 }
        /// <summary>
        ///     Receives the selection.
        /// </summary>
        /// <param name="m">The m.</param>
        private void ReceiveSelection(ActorSelectionMessage m)
        {
            var selection = new ActorSelection(Self, m.Elements.ToArray());

            selection.Tell(m.Message, Sender);
        }
Пример #32
0
 protected bool Equals(ActorSelection other)
 {
     return Equals(Anchor, other.Anchor) && Equals(Path, other.Path);
 }
Пример #33
0
 /// <summary>   
 ///     Receives the selection.
 /// </summary>
 /// <param name="m">The m.</param>
 private void ReceiveSelection(ActorSelectionMessage m)
 {
     var selection = new ActorSelection(Self, m.Elements.ToArray());
     selection.Tell(m.Message, Sender);
 }
Пример #34
0
 public Router AddRoutee(ActorSelection routee)
 {
     return new Router(logic, routees.Add(new ActorSelectionRoutee(routee)));
 }