本文整理汇总了C#中Akka.Actor.ActorRef.Tell方法的典型用法代码示例。如果您正苦于以下问题:C# ActorRef.Tell方法的具体用法?C# ActorRef.Tell怎么用?C# ActorRef.Tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akka.Actor.ActorRef
的用法示例。
在下文中一共展示了ActorRef.Tell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClientReceiveActor
public ClientReceiveActor(ActorRef actor, long repeat, TaskCompletionSource<bool> latch)
{
var received=0L;
var sent=0L;
Receive<Messages.Msg>(m =>
{
received++;
if(sent < repeat)
{
actor.Tell(m);
sent++;
}
else if(received >= repeat)
{
latch.SetResult(true);
}
});
Receive<Messages.Run>(r =>
{
var msg = new Messages.Msg();
for(int i = 0; i < Math.Min(1000, repeat); i++)
{
actor.Tell(msg);
sent++;
}
});
Receive<Messages.Started>(s => Sender.Tell(s));
}
示例2: PersistentViewSpec
public PersistentViewSpec()
: base(Configuration("inmem", "PersistentViewSpec"))
{
_prefProbe = CreateTestProbe();
_viewProbe = CreateTestProbe();
_pref = ActorOf(() => new TestPersistentActor(Name, _prefProbe.Ref));
_pref.Tell("a");
_pref.Tell("b");
_prefProbe.ExpectMsg("a-1");
_prefProbe.ExpectMsg("b-2");
}
示例3: Dispatcher
public Dispatcher(ActorRef journalWriter, ActorRef executor)
{
_executor = executor;
_journalWriter = journalWriter;
Receive<Command>(command => _journalWriter.Tell(new RequestContext(command, Sender)));
Receive<Query>(query => _executor.Tell(new RequestContext(query, Sender)));
}
示例4: PreStart
protected override void PreStart()
{
//Fire up a TestRunCoordinator instance and subscribe to FactData messages when they arrive
if (UseTestCoordinator)
{
TestCoordinatorActorRef = Context.ActorOf<TestRunCoordinator>();
TestCoordinatorActorRef.Tell(new TestRunCoordinator.SubscribeFactCompletionMessages(Self));
}
}
示例5: PersistentView_should_run_updates_on_user_request
public void PersistentView_should_run_updates_on_user_request()
{
_view = ActorOf(() => new TestPersistentView(Name, _viewProbe.Ref, TimeSpan.FromSeconds(5), null));
_viewProbe.ExpectMsg("replicated-a-1");
_viewProbe.ExpectMsg("replicated-b-2");
_pref.Tell("c");
_prefProbe.ExpectMsg("c-3");
_view.Tell(new Update(isAwait: false));
_viewProbe.ExpectMsg("replicated-c-3");
}
示例6: AkkaJournaler
public AkkaJournaler(ActorRef executor, int batchSize, IJournalWriter journalWriter)
{
_journalWriter = journalWriter;
BatchSize = batchSize;
_executor = executor;
Receive<RequestContext>(t => Accept(t));
Receive<ReceiveTimeout>(_ => Go());
Receive<JournalAcknowledgement>(_ => _executor.Tell(_waitingForJournalAck.Dequeue()));
SetReceiveTimeout(Interval);
}
示例7: TellInternal
protected override void TellInternal(object message, ActorRef sender)
{
unregister();
if (sender != NoSender)
{
sender.Tell(new CompleteFuture(() => result.TrySetResult(message)));
}
else
{
result.TrySetResult(message);
}
}
示例8: ClusterDomainEventPublisherSpec
public ClusterDomainEventPublisherSpec()
{
_memberSubscriber = CreateTestProbe();
Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.IMemberEvent));
Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.LeaderChanged));
_publisher = Sys.ActorOf(Props.Create<ClusterDomainEventPublisher>());
//TODO: If parent told of exception then test should fail (if not expected in some way)?
_publisher.Tell(new InternalClusterAction.PublishChanges(g0));
_memberSubscriber.ExpectMsg(new ClusterEvent.MemberUp(aUp));
_memberSubscriber.ExpectMsg(new ClusterEvent.LeaderChanged(aUp.Address));
}
示例9: Print
protected override void Print(LogEvent m)
{
if(m.Message is ForwardAllEventsTo)
{
_forwarder = ((ForwardAllEventsTo)m.Message).Forwarder;
_forwarder.Tell("OK");
}
else if(_forwarder != null)
{
_forwarder.Forward(m);
}
else
{
base.Print(m);
}
}
示例10: ReceiveMessage
protected override bool ReceiveMessage(object message)
{
var strMessage = message as string;
switch(strMessage)
{
case "complexRequest":
_replyTo = Sender;
var worker = TestActorRef.Create<WorkerActor>(System);
worker.Tell("work");
return true;
case "complexRequest2":
var worker2 = TestActorRef.Create<WorkerActor>(System);
worker2.Tell(Sender, Self);
return true;
case "workDone":
_replyTo.Tell("complexReply", Self);
return true;
case "simpleRequest":
Sender.Tell("simpleReply", Self);
return true;
}
return false;
}
示例11: SpecialHandle
protected virtual bool SpecialHandle(object message, ActorRef sender)
{
var w = message as Watch;
if(w != null)
{
if(w.Watchee == this && w.Watcher != this)
{
w.Watcher.Tell(new DeathWatchNotification(w.Watchee, existenceConfirmed: false, addressTerminated: false));
}
return true;
}
if(message is Unwatch)
return true; //Just ignore
var identify = message as Identify;
if(identify != null)
{
sender.Tell(new ActorIdentity(identify.MessageId, null));
return true;
}
var sel = message as ActorSelectionMessage;
if(sel != null)
{
var selectionIdentify = sel.Message as Identify;
if(selectionIdentify != null)
{
if(!sel.WildCardFanOut)
sender.Tell(new ActorIdentity(selectionIdentify.MessageId, null));
}
else
{
_eventStream.Publish(new DeadLetter(sel.Message, sender.IsNobody() ? _provider.DeadLetters : sender, this));
}
return true;
}
return false;
}
示例12: Receive
protected override bool Receive(object message)
{
var type = message.ToString();
switch (type)
{
case "complexRequest":
{
_replyTo = Sender;
var worker = Context.ActorOf(Props.Create<WorkerActor>());
worker.Tell("work");
break;
}
case "complexRequest2":
{
var worker = Context.ActorOf(Props.Create<WorkerActor>());
worker.Tell(new ReplyTo(Sender));
break;
}
case "workDone":
_replyTo.Tell("complexReply");
break;
case "simpleRequest":
Sender.Tell("simpleReply");
break;
}
return true;
}
示例13: ChaosApp
public ChaosApp(ActorRef probe)
{
_probe = probe;
_destination = Context.ActorOf(Props.Create(() => new ChaosDestination(_probe)), "destination");
_sender = Context.ActorOf(Props.Create(() => new ChaosSender(_destination, _probe)), "sender");
Receive<Start>(_ =>
{
for (int i = 1; i < GuaranteedDeliveryFailureSpec.NumberOfMessages; i++)
{
_sender.Tell(i);
}
});
Receive<ProcessingFailure>(x => _sender.Tell(x.I));
Receive<JournalingFailure>(x => _sender.Tell(x.I));
}
示例14: OnReceive
protected override void OnReceive(object message)
{
PatternMatch.Match(message)
.With<InitializeLogger>(m =>
{
var bus = m.LoggingBus;
bus.Subscribe(this.Self, typeof(SetTarget));
bus.Subscribe(this.Self, typeof(UnhandledMessage));
Sender.Tell(new LoggerInitialized());
})
.With<SetTarget>(m =>
{
dst = m.Ref;
dst.Tell("OK");
})
.With<LogEvent>(m => dst.Tell(m))
.With<UnhandledMessage>(m => dst.Tell(m));
}
示例15: Deliver
/// <summary>
/// Delivers the specified message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="sender">The sender.</param>
/// <param name="pathIndex">Index of the path.</param>
/// <param name="current">The current.</param>
private void Deliver(object message, ActorRef sender, int pathIndex, ActorRef current)
{
if (pathIndex == Elements.Length)
{
current.Tell(message, sender);
}
else
{
SelectionPathElement element = Elements[pathIndex];
if (current is ActorRefWithCell)
{
var withCell = (ActorRefWithCell) current;
if (element is SelectParent)
Deliver(message, sender, pathIndex + 1, withCell.Parent);
else if (element is SelectChildName)
Deliver(message, sender, pathIndex + 1,
withCell.GetSingleChild(element.AsInstanceOf<SelectChildName>().Name));
}
else
{
SelectionPathElement[] rest = Elements.Skip(pathIndex).ToArray();
current.Tell(new ActorSelectionMessage(message, rest), sender);
}
}
}