private void WatchStock(WatchStockMessage message) { // TODO // if the agent that handle the stock symbol in the message does not exist, // create a new one and add the instance to the local state // -- Agent can be created using the StockActor.Create function _chartingActor.Post(new AddChartSeriesMessage(message.StockSymbol)); }
private void WatchStock(WatchStockMessage message) { if (!_stockActors.ContainsKey(message.StockSymbol)) { return; } _chartingActor.Tell(new RemoveChartSeriesMessage(message.StockSymbol)); _stockActors[message.StockSymbol].Tell(new UnSubscribeFromNewStockPricesMessage(_chartingActor)); }
private void WatchStock(WatchStockMessage message) { bool childActorNeedsCreating = !StockActors.ContainsKey(message.StockSymbol); if (childActorNeedsCreating) { IActorRef newChildActor = Context.ActorOf(Props.Create(() => new StockActor(message.StockSymbol)), "StockActor_" + message.StockSymbol); StockActors.Add(message.StockSymbol, newChildActor); } ChartingActor.Tell(new AddChartSeriesMessage(message.StockSymbol)); StockActors[message.StockSymbol].Tell(new SubscibeToNewStockPriceMessage(ChartingActor)); }
private void WatchStock(WatchStockMessage a) { bool childActorNeedsCreating = !_stockActors.ContainsKey(a.StockSymbol); if (childActorNeedsCreating) { var newChildActor = Context.ActorOf(Props.Create(() => new StockActor(a.StockSymbol)), "StockActor_" + a.StockSymbol); _stockActors.Add(a.StockSymbol, newChildActor); } _chartingActor.Tell(new AddChartSeriesMessage(a.StockSymbol)); _stockActors[a.StockSymbol].Tell(new SubscribeToNewStockPriceMessage(_chartingActor)); }
private void WatchStock(WatchStockMessage message) { var childActorNeedsCreating = !_stockActors.ContainsKey(message.StockSymbol); if (childActorNeedsCreating) { IActorRef newChildActor = Context.ActorOf( Props.Create(() => new StockActor(message.StockSymbol)), $"StockActor_{message.StockSymbol}" ); _stockActors.Add(message.StockSymbol, newChildActor); } _chartingActor.Tell(new AddChartSeriesMessage(message.StockSymbol)); _stockActors[message.StockSymbol]. Tell(new SubscribeToNewStockPricesMessage(_chartingActor)); }
private void WatchStock(WatchStockMessage message) { // TASK // if the agent that handle the stock symbol in the message does not exist, // create a new one and add the instance to the local state // -- Agent can be created using the StockActor.Create function bool childActorNeedsCreating = !_stockActors.ContainsKey(message.StockSymbol); if (childActorNeedsCreating) { var newChildActor = StockActor.Create(message.StockSymbol); _stockActors.Add(message.StockSymbol, newChildActor); } _chartingActor.Post(new AddChartSeriesMessage(message.StockSymbol)); _stockActors[message.StockSymbol] .Post(new SubscribeToNewStockPricesMessage(_chartingActor)); }
/// <summary> /// Called when a <see cref="WatchStockMessage" /> is received. /// </summary> /// <param name="message"></param> private void WatchStock(WatchStockMessage message) { this.CreateChildActorIfNotExists(message.StockSymbol); this._chartingActor?.Tell(new AddChartSeriesMessage(message.StockSymbol)); this._stockActors[message.StockSymbol].Tell(new SubscribeToNewStockPricesMessage(this._chartingActor)); }