本文整理汇总了C#中IActorRef.Forward方法的典型用法代码示例。如果您正苦于以下问题:C# IActorRef.Forward方法的具体用法?C# IActorRef.Forward怎么用?C# IActorRef.Forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActorRef
的用法示例。
在下文中一共展示了IActorRef.Forward方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestProjection
public TestProjection(IActorRef probe)
{
_probe = probe;
OnEvent<TestEvent>(e =>
{
_probe.Forward(e);
});
OnQuery<TestQuery>(q =>
{
_probe.Forward(q);
});
}
示例2: Master
public Master()
{
mapper = Context.ActorOf(
Props.Create<Mapper>()
.WithRouter(new RoundRobinPool(NrMappers))
);
reducer = Context.ActorOf(
Props.Create<Reducer>()
.WithRouter(new RoundRobinPool(NrReducers))
);
aggregator = Context.ActorOf(Props.Create<Aggregator>());
// 1. forward a string to mapper
Receive<string>(s => mapper.Tell(s));
// 2. forward map result to reducer
Receive<MapResult>(m => reducer.Tell(m));
// 3. forward reduce result to aggregator
Receive<ReduceResult>(r => aggregator.Tell(r));
// allow asking for aggregated result at any time
Receive<GetResult>(g => aggregator.Forward(g));
}
示例3: TestService
public TestService(IActorRef testActorRef)
{
ReceiveAny(msg =>
{
testActorRef.Forward(msg);
Sender.Tell(msg.ToString() + "-ack");
});
}
示例4: ForwardActor
public ForwardActor(IActorRef testActor)
{
_testActor = testActor;
Context.Parent.Tell("one");
Receive<string>(s => s == "one", c =>
{
_testActor.Forward("two");
});
}
示例5: ProbeRelay
public ProbeRelay(IActorRef target)
{
ReceiveAny(o => target.Forward(o));
}
示例6: ParentWithChildPropsActor
public ParentWithChildPropsActor(Props childProps)
{
_childActor = Context.ActorOf(childProps, "child");
Receive<ChildDoWorkMessage>(m => _childActor.Forward(m));
}
示例7: Active
private Receive Active(IActorRef receptionist)
{
return message =>
{
if (message is Send)
{
var send = (Send)message;
receptionist.Forward(new PublishSubscribe.Send(send.Path, send.Message, send.LocalAffinity));
}
else if (message is SendToAll)
{
var sendToAll = (SendToAll)message;
receptionist.Forward(new PublishSubscribe.SendToAll(sendToAll.Path, sendToAll.Message));
}
else if (message is Publish)
{
var publish = (Publish)message;
receptionist.Forward(new PublishSubscribe.Publish(publish.Topic, publish.Message));
}
else if (message is HeartbeatTick)
{
if (!_failureDetector.IsAvailable)
{
_log.Info("Lost contact with [{0}], restablishing connection", receptionist);
SendGetContacts();
ScheduleRefreshContactsTick(_settings.EstablishingGetContactsInterval);
Context.Become(Establishing);
_failureDetector.HeartBeat();
}
else
{
receptionist.Tell(ClusterReceptionist.Heartbeat.Instance);
}
}
else if (message is ClusterReceptionist.HeartbeatRsp)
{
_failureDetector.HeartBeat();
}
else if (message is RefreshContactsTick)
{
receptionist.Tell(ClusterReceptionist.GetContacts.Instance);
}
else if (message is ClusterReceptionist.Contacts)
{
var contacts = (ClusterReceptionist.Contacts)message;
// refresh of contacts
if (contacts.ContactPoints.Count > 0)
{
_contactPaths = contacts.ContactPoints.Select(ActorPath.Parse).ToImmutableHashSet();
_contacts = _contactPaths.Select(Context.ActorSelection).ToArray();
}
PublishContactPoints();
}
else if (message is ActorIdentity)
{
// ok, from previous establish, already handled
}
else
{
return ContactPointMessages(message);
}
return true;
};
}
示例8: Active
private Receive Active(IActorRef receptionist)
{
return message =>
message.Match()
.With<Send>(send =>
receptionist.Forward(new Send(send.Path, send.Message, send.LocalAffinity)))
.With<SendToAll>(toAll =>
receptionist.Forward(new SendToAll(toAll.Path, toAll.Message)))
.With<Publish>(publish =>
receptionist.Forward(new Publish(publish.Topic, publish.Message)))
.With<InternalMessage>(m =>
{
switch (m)
{
case InternalMessage.HeartbeatTick:
if (!_failureDetector.IsAvailable)
{
Log.Info("Lost contact with [{0}], restablishing connection", receptionist);
SendGetContacts();
ScheduleRefreshContactsTick(Settings.EstablishingGetContactsInterval);
Context.Become(Establishing);
_failureDetector.HeartBeat();
}
else
{
receptionist.Tell(ClusterReceptionist.Heartbeat.Instance);
}
break;
case InternalMessage.RefreshContactsTick:
receptionist.Tell(ClusterReceptionist.GetContacts.Instance);
break;
}
})
.With<ClusterReceptionist.HeartbeatRsp>(_ => _failureDetector.HeartBeat())
.With<ClusterReceptionist.Contacts>(contacts =>
{
if (contacts.ContactPoints.Length != 0)
_contacts = contacts.ContactPoints.Select(Context.ActorSelection).ToArray();
})
.With<Terminated>(terminated =>
{
Log.Info("Lost contact with [{0}], restablishing connection", receptionist);
SendGetContacts();
ScheduleRefreshContactsTick(Settings.EstablishingGetContactsInterval);
Context.Become(Establishing);
})
.With<ActorIdentity>(_ => { /* ok, from previous establish, already handled */ })
.WasHandled;
}
示例9: ForwardTo
private void ForwardTo( IActorRef sender, GithubValidatorActor.InvalidRepo repo )
{
sender.Forward( repo );
}
示例10: CreateWorkingWriter
IActorRef CreateWorkingWriter(IActorRef relay = null)
{
return Sys.ActorOf(conf =>
{
conf.Receive<PersistenceRequest>((r, ctx) => {
if (relay != null)
relay.Forward(r);
ctx.Sender.Tell(new PersistenceSuccess(r.PersistenceID));
});
});
}
示例11: ProbeActor
public ProbeActor(IActorRef testActor)
{
_testActor = testActor;
Receive<WatchIt>(w =>
{
Context.Watch(w.Watchee);
Sender.Tell(Ack.Instance);
});
Receive<UnwatchIt>(w =>
{
Context.Unwatch(w.Watchee);
Sender.Tell(Ack.Instance);
});
Receive<Terminated>(t => _testActor.Forward(new WrappedTerminated(t)));
ReceiveAny(msg => _testActor.Forward(msg));
}
示例12: ForwardActor
public ForwardActor(IActorRef testActor)
{
_testActor = testActor;
ReceiveAny(msg =>
{
_testActor.Forward(msg);
});
}
示例13: TestService
public TestService(IActorRef testActorRef)
{
Receive<string>(cmd => cmd.Equals("shutdown"), msg =>
{
Context.System.Terminate();
});
ReceiveAny(msg =>
{
testActorRef.Forward(msg);
Sender.Tell(new Reply(msg.ToString() + "-ack", Cluster.Get(Context.System).SelfAddress));
});
}