static async Task Run(IActorSystem system) { var item = system.TypedActorOf<InventoryItem>("12345"); await item.Tell(new Create("XBOX1")); await Print(item); await item.Tell(new CheckIn(10)); await Print(item); await item.Tell(new CheckOut(5)); await Print(item); await item.Tell(new Rename("XBOX360")); await Print(item); await item.Tell(new Deactivate()); await Print(item); var inventory = system.TypedActorOf<Inventory>("#"); var items = await inventory.Ask(new GetInventoryItems()); Console.WriteLine($"\n# of items in inventory: {items.Length}"); Array.ForEach(items, Print); var total = await inventory.Ask(new GetInventoryItemsTotal()); Console.WriteLine($"\nTotal of all items inventory: {total}"); }
static async Task Run(IActorSystem system) { var item = system.TypedActorOf <InventoryItem>("12345"); await item.Tell(new Create("XBOX1")); await Print(item); await item.Tell(new CheckIn(10)); await Print(item); await item.Tell(new CheckOut(5)); await Print(item); await item.Tell(new Rename("XBOX360")); await Print(item); await item.Tell(new Deactivate()); await Print(item); var inventory = system.TypedActorOf <Inventory>("#"); var items = await inventory.Ask(new GetInventoryItems()); Console.WriteLine($"\n# of items in inventory: {items.Length}"); Array.ForEach(items, Print); var total = await inventory.Ask(new GetInventoryItemsTotal()); Console.WriteLine($"\nTotal of all items inventory: {total}"); }
public async Task Request_response() { var actor = system.TypedActorOf <ITestActor>("foo"); // below won't compile // actor.Tell(new object()); Assert.DoesNotThrowAsync(async() => await(actor < new TestActorCommand())); Assert.That(await(result(new TestActorQuery()) > actor), Is.EqualTo(42)); }
public async void Request_response() { var actor = system.TypedActorOf <TestActor>("foo"); // below won't compile // actor.Tell(new object()); Assert.DoesNotThrow(async() => await actor.Tell(new TestActorCommand())); Assert.That(await actor.Ask(new TestActorQuery()), Is.EqualTo(42)); }
public async void Actor_to_stream() { var producer = system.TypedActorOf <TestProducerActor>("p"); var consumer = system.TypedActorOf <TestConsumerActor>("c"); await consumer.Call(x => x.Subscribe()); await producer.Call(x => x.Produce("event")); await Task.Delay(100); var received = await consumer.Get(x => x.Received); Assert.That(received.Count, Is.EqualTo(1)); Assert.That(received[0], Is.EqualTo("event")); }
static async Task Run(IActorSystem system) { var e0 = system.TypedActorOf <Employee>("E0"); var e1 = system.TypedActorOf <Employee>("E1"); var e2 = system.TypedActorOf <Employee>("E2"); var e3 = system.TypedActorOf <Employee>("E3"); var e4 = system.TypedActorOf <Employee>("E4"); var m0 = system.TypedActorOf <Manager>("M0"); var m1 = system.TypedActorOf <Manager>("M1"); await m0.Tell(new AddDirectReport { Employee = e0 }); await m0.Tell(new AddDirectReport { Employee = e1 }); await m0.Tell(new AddDirectReport { Employee = e2 }); await m1.Tell(new AddDirectReport { Employee = e3 }); await m1.Tell(new AddDirectReport { Employee = e4 }); await e1.Tell(new Promote { NewLevel = 80 }); await e4.Tell(new Promote { NewLevel = 80 }); }
static async Task Run(IActorSystem system) { var item = system.TypedActorOf<InventoryItem>("12345"); await item.Call(x => x.Create("XBOX1")); await Print(item); await item.Call(x => x.CheckIn(10)); await Print(item); await item.Call(x => x.CheckOut(5)); await Print(item); await item.Call(x => x.Rename("XBOX360")); await Print(item); await item.Call(x => x.Deactivate()); await Print(item); }
static async Task Run() { var item = system.TypedActorOf <InventoryItem>("12345"); await item.Tell(new Create("XBOX1")); await Print(item); await item.Tell(new CheckIn(10)); await Print(item); await item.Tell(new CheckOut(5)); await Print(item); await item.Tell(new Rename("XBOX360")); await Print(item); }
static async Task Run(IActorSystem system) { var e0 = system.TypedActorOf<Employee>("E0"); var e1 = system.TypedActorOf<Employee>("E1"); var e2 = system.TypedActorOf<Employee>("E2"); var e3 = system.TypedActorOf<Employee>("E3"); var e4 = system.TypedActorOf<Employee>("E4"); var m0 = system.TypedActorOf<Manager>("M0"); var m1 = system.TypedActorOf<Manager>("M1"); await m0.Tell(new AddDirectReport {Employee = e0}); await m0.Tell(new AddDirectReport {Employee = e1}); await m0.Tell(new AddDirectReport {Employee = e2}); await m1.Tell(new AddDirectReport {Employee = e3}); await m1.Tell(new AddDirectReport {Employee = e4}); await e1.Tell(new Promote {NewLevel = 80}); await e4.Tell(new Promote {NewLevel = 80}); }
static async Task Run(IActorSystem system) { var item = system.TypedActorOf <InventoryItem>("12345"); await item.Call(x => x.Create("XBOX1")); await Print(item); await item.Call(x => x.CheckIn(10)); await Print(item); await item.Call(x => x.CheckOut(5)); await Print(item); await item.Call(x => x.Rename("XBOX360")); await Print(item); await item.Call(x => x.Deactivate()); await Print(item); }
public ChatClient(IActorSystem system, string user, string room) { this.user = system.TypedActorOf <IChatUser>(user); this.system = system; RoomName = room; }
public ChatClient(IActorSystem system, string user, string room) { this.user = system.TypedActorOf<ChatUser>(user); this.room = system.StreamOf<SimpleMessageStreamProvider>(room); }
public ChatClient(IActorSystem system, string user, string room) { this.user = system.TypedActorOf <ChatUser>(user); this.room = system.StreamOf <SimpleMessageStreamProvider>(room); }
static async Task Run(IActorSystem system) { var copier = system.TypedActorOf <ICopier>("1"); await copier.Tell(new Start()); }