问题描述
我想使用scala从本地计算机启动远程角色。我是否可以开始在远程计算机上运行角色,而无需在远程计算机中手动启动某种服务器程序。我有一个演员主,必须启动一些远程演员。那么我应该怎么做呢?还是可以在不执行我必须首先连接到的远程计算机上才能启动新的远程参与者的程序的情况下执行此操作。
I want to start remote actors from my local computer using scala . Can I just start running the actors on the remote computer without manually starting a server program of some kind in the remote computer. I have a master actor which has to start some remote actors. So any ideas on how I should do it? or can I do it without executing some kind of program on the remote computer to which i have to connect first in order to start new remote actors.
推荐答案
您需要在要连接的远程端运行一个程序。在该程序中,有一个参与者,该参与者监听来自本地计算机的消息并创建其他参与者。
You would need to have a program running on the remote side that you would have to connect to. In that program have an actor that listens for messages from your local computer and creates other actors.
例如-本地:
remoteActor ! Props(new SomeActor)
远程:
def receive = {
case p @ Props(_,_,_,_) =>
val actor = context.actorOf(p)
sender ! actor
//...
}
这篇关于如何在Scala中启动远程角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!