Created
March 20, 2012 14:49
-
-
Save denen99/2136439 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(pubsub_srv). | |
start_link() -> | |
{ok,PID} = eredis_sub:start_link(), | |
register(eredispid,PID), | |
{ok, PID}. | |
receiver(Sub) -> | |
receive | |
Msg -> | |
io:format("received ~p~n", [Msg]), | |
ack_message(Sub), | |
?MODULE:receiver(Sub) | |
end. | |
%This is called by other modules | |
subscribe_channel(Channel) -> | |
Sub = whereis(eredispid), | |
_Receiver = spawn_link(fun () -> | |
eredis_sub:controlling_process(Sub), | |
eredis_:sub:subscribe(Sub, [<<Channel>>]), | |
receiver(Sub) | |
end), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment