Sending and Receiving Events
Everything we’ve done so far is setting us up to do one thing: process events. Just as controllers receive requests, channels receive events. With channels, we receive a message containing an event name, such as new_message, and a payload of arbitrary data.
Each channel module has three ways to receive events. You’ll learn more about these callback functions in detail soon. For now, know that handle_in receives direct channel events, handle_out intercepts broadcast events, and handle_info receives OTP messages.
Taking Our Channels for a Trial Run
To test-drive everything we’ve put together so far, let’s make our join function send our channel client a :ping message every five seconds, like this: