From 2a3343e5c72b98a3c57b9d60e3d334ed19a731bb Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Wed, 31 Aug 2011 20:26:42 -0500 Subject: [PATCH] Move the irc_amqp_listener to be underneath the irc_object_sup --- irc/irc_conn.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/irc/irc_conn.erl b/irc/irc_conn.erl index db68f7d..f7dc563 100644 --- a/irc/irc_conn.erl +++ b/irc/irc_conn.erl @@ -98,7 +98,7 @@ do_line(Line, State) -> % end of MOTD, which should normally be sent on connect error_logger:info_msg("Joining my channels now.", []), {_, _, _, _, Channels} = State#irc_state.config, - lists:foreach(fun join_channel/1, Channels), + lists:foreach(fun(Channel) -> join_channel(Channel, State) end, Channels), State#irc_state{joined = true}; "PRIVMSG" -> do_privmsg(Command), @@ -130,10 +130,11 @@ code_change(_OldVsn, State, _Extra) -> send_command(Command) -> gen_server:cast(self(), {send_command, Command}). -join_channel(Channel) -> +join_channel(Channel, State) -> Command = #irc_command{command = "JOIN", middles = [Channel]}, send_command(Command), - irc_amqp_listener:start_link(self(), Channel, "foobar"). %% TODO: fix routing key + #irc_state{ object_sup = ObjectSup } = State, + {ok, _ChildPid} = irc_object_sup:add_amqp_listener(ObjectSup, self(), Channel). %% @doc Splits a buffer into full lines, keeping whatever is left over %% Returns either {ok, [Line], Remaining} or none. -- 2.11.0