From: Matt Mullins Date: Sat, 4 May 2013 06:35:42 +0000 (-0700) Subject: Return and save the AMQP Channel pid. X-Git-Tag: v9.5~3 X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=b6f1ba7c90b7fb5a294bba87f9d6f875d432984c;p=erlbot.git Return and save the AMQP Channel pid. --- diff --git a/amqp/amqp_bot_listener.erl b/amqp/amqp_bot_listener.erl index bd8a934..a0732b3 100644 --- a/amqp/amqp_bot_listener.erl +++ b/amqp/amqp_bot_listener.erl @@ -42,4 +42,4 @@ listen_for_events(RoutingKeyString) -> no_ack = true }, Pid), - {ok, ConsumerTag}. + {ok, ConsumerTag, Channel}. diff --git a/irc/irc_amqp_listener.erl b/irc/irc_amqp_listener.erl index ceca5aa..da33e92 100644 --- a/irc/irc_amqp_listener.erl +++ b/irc/irc_amqp_listener.erl @@ -25,8 +25,8 @@ start_link(ConnectionPid, RoutingKey) -> gen_server:start_link(?MODULE, {ConnectionPid, RoutingKey}, []). init({ConnectionPid, RoutingKey}) -> - {ok, _} = amqp_bot_listener:listen_for_events(RoutingKey), - {ok, {ConnectionPid}}. + {ok, _, ListeningChannel} = amqp_bot_listener:listen_for_events(RoutingKey), + {ok, {ConnectionPid, ListeningChannel}}. %% Ignore the message indicating that the listener is operating correctly handle_info(#'basic.consume_ok'{}, State) -> @@ -35,7 +35,7 @@ handle_info(#'basic.consume_ok'{}, State) -> handle_info( { #'basic.deliver'{routing_key = RoutingKey}, #amqp_msg{payload = BinContent} }, - State = {ConnectionPid}) -> + State = {ConnectionPid, ListeningChannel}) -> error_logger:info_msg("Got a message ~p for routing key ~p~n", [BinContent, RoutingKey]), [_, _, DestinationKey] = string:tokens(binary_to_list(RoutingKey), "."),