From: Matt Mullins Date: Thu, 1 Sep 2011 20:31:49 +0000 (-0500) Subject: Refactored the way commands are sent from the AMQP listener to the irc_conn X-Git-Tag: v5~7 X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=0cc604ace3f03725b4fcd067094d35dadc6d3f43;p=erlbot.git Refactored the way commands are sent from the AMQP listener to the irc_conn --- diff --git a/irc/irc_amqp_listener.erl b/irc/irc_amqp_listener.erl index b8c02a2..2218955 100644 --- a/irc/irc_amqp_listener.erl +++ b/irc/irc_amqp_listener.erl @@ -35,5 +35,5 @@ handle_info( Command = #irc_command{ command = "PRIVMSG", middles = [ Destination ], trailing = Content }, - gen_server:cast(ConnectionPid, {send_command, Command}), + irc_conn:send_command(ConnectionPid, Command), {noreply, State}. diff --git a/irc/irc_conn.erl b/irc/irc_conn.erl index d8d3d5e..6d79256 100644 --- a/irc/irc_conn.erl +++ b/irc/irc_conn.erl @@ -3,7 +3,8 @@ -vsn(2). -export([ - start_link/3 + start_link/3, + send_command/2 ]). -export([ @@ -31,6 +32,9 @@ start_link(Instance, Supervisor, TableId) -> gen_server:start_link(?MODULE, {Instance, Supervisor, TableId}, []). +send_command(Pid, Command) -> + gen_server:cast(Pid, {send_command, Command}). + init({Instance, Supervisor, TableId}) -> ets:insert(TableId, {irc_conn_pid, self()}), % record the connection PID in the table