Beispiel #1
0
        private async void HandleMessage(TrivaModel message)
        {
            try
            {
                var response = await _restActor.Ask <ResponseModel>(new RestApi.RestActor.RestRequestModel(message.Number, "trivia"));

                Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            RandomApi _randomApi   = new RandomApi();
            var       randomSystem = ActorSystem.Create("RandomStuffActor");
            var       restActor    = randomSystem.ActorOf(Props.Create(() => new RestApi.RestActor.RestActor(_randomApi)));
            var       masterJedi   = randomSystem.ActorOf(Props.Create(() => new MasterJediActor.MasterJediActor(restActor)), "Obi-Wan");

            for (int j = 1; j <= 10; j++)
            {
                //if (j % 2 == 0)
                //{
                //    var message = new MathActor.MathModel(j);
                //    masterJedi.Tell(message);
                //}
                //else
                //{
                var message = new TriviaActor.TrivaModel(j);
                masterJedi.Tell(message);
                //}
            }

            Console.Read();
        }