Skip to content

Instantly share code, notes, and snippets.

@denen99
Created March 20, 2012 16:03
Show Gist options
  • Save denen99/2137527 to your computer and use it in GitHub Desktop.
Save denen99/2137527 to your computer and use it in GitHub Desktop.
-module(pubsub_srv).
start_link() ->
{ok,PID} = eredis_sub:start_link(),
register(eredispid,PID),
_Receiver = spawn_link(fun () ->
eredis_sub:controlling_process(PID),
receiver(PID)
end),
{ok, PID}.
receiver(Sub) ->
receive
Msg ->
io:format("received ~p~n", [Msg]),
ack_message(Sub),
?MODULE:receiver(Sub)
end.
subscribe_channel(Channel) ->
Sub = whereis(eredispid),
eredis_:sub:subscribe(Sub, [<<Channel>>]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment