可以使用 actor.send()
或 actor.offer()
向 Actor 发送消息
一旦我的 Actor 从其 channel 收到消息,我想返回响应。我该怎么做呢?我没有看到任何明显的内置方法。
最佳答案
您需要请求Actor
的 channel
,
如documented :
[The
actor
coroutine builder] Launches new coroutine that is receiving messages from its mailbox channel and returns a reference to the coroutine as anActorJob
. The resulting object can be used to send messages to this coroutine.
这是一个简单的 example .
关于Kotlin Actor 到 Actor 的通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46995149/