如何在Scala中启动远程角色

编程入门 行业动态 更新时间:2024-10-26 16:35:05
本文介绍了如何在Scala中启动远程角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用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中启动远程角色

本文发布于:2023-11-25 08:51:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角色   如何在   Scala

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!