View Source Kalevala.Communication.Channel behaviour (kalevala v0.1.0)
A GenServer to handle channel communication
Link to this section Summary
Types
The "topic" in the channel pub/sub
Config is saved and stored in the GenServer, passed in for each callback
Options are for each subscribe/publish request
Callbacks
Called during initialization
Called before a message is allowed to publish on the channel
Called before a pid is allowed to subscribe to a channel
Called before a pid is allowed to unsubscribe to a channel
Functions
Returns a specification to start this module under a supervisor.
Publish a new message
Subscribe to a new channel
Unsubscribe to a new channel
Link to this section Types
@type channel_name() :: String.t()
The "topic" in the channel pub/sub
This might be a simple global channel name or something specific to rooms,
maybe rooms:id
.
@type config() :: map()
Config is saved and stored in the GenServer, passed in for each callback
@type options() :: map()
Options are for each subscribe/publish request
This may contain information like charcater data
Link to this section Callbacks
Called during initialization
You can change any of the config you wish on start of the gen server
@callback publish_request(channel_name(), Kalevala.Event.message(), options(), config()) :: :ok
Called before a message is allowed to publish on the channel
@callback subscribe_request(channel_name(), options(), config()) :: :ok
Called before a pid is allowed to subscribe to a channel
@callback unsubscribe_request(channel_name(), options(), config()) :: :ok
Called before a pid is allowed to unsubscribe to a channel
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Publish a new message
Subscribe to a new channel
Allows for the callback_module to reject subscription
Unsubscribe to a new channel
Allows for the callback_module to reject unsubscription