简体   繁体   中英

Kotlin actor to actor communication

An actor can be sent a message with actor.send() or actor.offer() Once my actor gets the message from its channel I'd like to return a response. How do I do this? I don't see any obvious built in method.

You need to request the Actor 's channel , as documented :

[The actor coroutine builder] Launches new coroutine that is receiving messages from its mailbox channel and returns a reference to the coroutine as an ActorJob . The resulting object can be used to send messages to this coroutine.

Here's a simple example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM