pushex v0.2.0 Pushex.EventHandler
This module defines utilities to handle events when sending notification.
Events can be implemented to log requests, responses or save them in a database for example.
Under the hood, it uses a GenEvent
, so you will basically need to implement
handle_event
for the events you care about.
The following events are emitted:
{:request, request, {pid, ref}}
{:response, response, request, {pid, ref}}
Examples
defmodule MyPushEventHandler do use Pushex.EventHandler
def handle_event({:request, request, {pid, ref}}, state) do
# do whatever you want with the request
# for example, logging or saving in a DB
{:ok, state}
end
def handle_event({:response, response, request, {pid, ref}}, state) do
# do whatever you want with the response and request
{:ok, state}
end end