Elforama
Elforama

Reputation: 652

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.

Upvotes: 4

Views: 1396

Answers (1)

s1m0nw1
s1m0nw1

Reputation: 81939

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.

Upvotes: 6

Related Questions