protected override bool Receive(object message)
{
return message.Match()
.With<OnNext>(next =>
{
var msg = (Msg)next.Element;
_queue.Add(msg.Id, msg.ReplyTo);
if (_queue.Count > 10)
throw new InvalidOperationException($"queued too many: {_queue.Count}");
_router.Route(new Work(msg.Id), Self);
})
.With<Reply>(reply =>
{
_queue[reply.Id].Tell(new Done(reply.Id));
_queue.Remove(reply.Id);
})
.WasHandled;
}
}