From 0cc604ace3f03725b4fcd067094d35dadc6d3f43 Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Thu, 1 Sep 2011 15:31:49 -0500 Subject: [PATCH] Refactored the way commands are sent from the AMQP listener to the irc_conn --- irc/irc_amqp_listener.erl | 2 +- irc/irc_conn.erl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 -- 2.11.0