Cauldron2D.World.Presence (Cauldron2D v0.1.3)

Copy Markdown View Source

Who comes and goes in every world on the node, told to whoever asks.

Cauldron2D.World.Presence.subscribe()
receive do
  {:cauldron_players, world, :joined, id} -> ...
  {:cauldron_players, world, :left, id} -> ...
end

A subscribed process is sent a message for every join and leave in every Cauldron2D.World until it unsubscribes or exits; world is the world's pid.

Summary

Functions

Tell every subscriber that id joined or left the world world.

Receive every world's joins and leaves in the calling process.

Stop receiving them.

Functions

broadcast(world, change, id)

@spec broadcast(pid(), :joined | :left, term()) :: :ok

Tell every subscriber that id joined or left the world world.

subscribe()

@spec subscribe() :: :ok

Receive every world's joins and leaves in the calling process.

unsubscribe()

@spec unsubscribe() :: :ok

Stop receiving them.