kalevala v0.1.0 Kalevala.Communication.Channel behaviour View Source
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
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
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
Link to this section Types
The "topic" in the channel pub/sub
This might be a simple global channel name or something specific to rooms,
maybe rooms:id
.
Config is saved and stored in the GenServer, passed in for each callback
Options are for each subscribe/publish request
This may contain information like charcater data
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
Link to this section Callbacks
Called during initialization
You can change any of the config you wish on start of the gen server
publish_request(channel_name, arg2, options, config)
View Sourcepublish_request(channel_name(), Kalevala.Event.message(), options(), config()) :: :ok
Called before a message is allowed to publish on the channel
subscribe_request(channel_name, options, config)
View Sourcesubscribe_request(channel_name(), options(), config()) :: :ok
Called before a pid is allowed to subscribe to a channel
unsubscribe_request(channel_name, options, config)
View Sourceunsubscribe_request(channel_name(), options(), config()) :: :ok
Called before a pid is allowed to unsubscribe to a channel