Skip to content

Instantly share code, notes, and snippets.

@bruinbrown
Created August 20, 2015 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruinbrown/14a8fc8cfa30ef667135 to your computer and use it in GitHub Desktop.
Save bruinbrown/14a8fc8cfa30ef667135 to your computer and use it in GitHub Desktop.
An example of using Ask in Akka.Net with Web API
public async Task<List<string>> RegisteredUsers(string serviceId)
{
var system = Global.System;
var serviceActorAddress = String.Format("/user/service/{0}", serviceId);
var resp = await system.ActorSelection(serviceActorAddress).Ask(RegisteredUsersRequest.Instance);
return resp;
}
public class ServiceActor : UntypedActor
{
List<string> _registeredUsers = new List<string>();
protected override void OnReceive(object message)
{
if(message is RegisteredUsersRequest)
{
Sender.Tell(_registeredUsers);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment