Skip to content

Instantly share code, notes, and snippets.

@shersh
Last active October 20, 2017 22:12
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 shersh/2dd43ac70ff95e20ed4c1e4b2f87b38c to your computer and use it in GitHub Desktop.
Save shersh/2dd43ac70ff95e20ed4c1e4b2f87b38c to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
var system = ActorSystem.Create("TestSystem");
var myActor = system.ActorOf(Props.Create(() => new MyActor());
using (var materializer = system.Materializer())
{
var source = Source.From(Enumerable.Range(1, 100));
//var sink = Sink.ForEach<int>(x => tcpActor.Tell(x));
var sink = Sink.ActorRef<int>(tcpActor, "Done");
var runnable = source.ToMaterialized(sink, Keep.Both);
runnable.Run(materializer);
}
Console.ReadLine();
}
}
public class MyActor : ReceiveActor
{
public MyActor()
{
Receive<string>(s => Console.WriteLine(s));
Receive<int>(i => Console.WriteLine("Got int: " + i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment