AmbientRun / Ambient

The multiplayer game engine
https://ambient.run
Apache License 2.0
3.78k stars 122 forks source link

Support `await`ing messages #710

Open philpax opened 1 year ago

philpax commented 1 year ago

At present, Messages require you to set up a subscription that lasts until you cancel it, which is not the most ergonomic for one-shot messages or for a back-and-forth protocol.

Instead, we should

let (source, value) = MyCoolMessage::receive().await;

(it feels to me that (value, source) is a better order, but (source, value) is consistent with subscribe)

Also relevant:

chaosprint commented 1 year ago

Is this related to https://github.com/AmbientRun/Ambient/issues/665

philpax commented 1 year ago

Nah, this is more of an API detail about how you use messages than how the messages are sent.