[erlang-questions] Strange error with client/server IRC code

bbrown <>
Wed Feb 27 21:09:18 CET 2008


This is some IRC code (this is your code orbitz if you are on); that whenever
when I call these type methods I get an error.  I dont have the error so this
post might be a little worthless right now; I am on a different environment
and going by memory.  But, basically the error is with the handle_cast
function.  It looks like it is not reaching any of the "handle_cast" calls. 
How do those work.  Sorry, when I get home, I will provide a little bit more
information.

----
    send_client_command(Irclib, "JOIN", [Channel, Pass]);
join(Irclib, Channel) when list(Channel) ->
	io:format("trace: join@~p~n", [Channel]),
	%% TODO: remove test code
    send_client_command(Irclib, "JOIN").

-----

handle_cast(irc_connect, #state{client=Client, state=disconn} = State) ->
    {ok, Sock} = connect_to_next_server(Client),
    {noreply, State#state{sock=Sock, state=connecting}};
handle_cast({irc_send_command, {"PING"}}, #state{sock=Sock, client=Client} =
State) ->
    send_command(Sock, {"PING", [dict_proc:fetch(nick, Client)]}),
    {noreply, State};
handle_cast({irc_send_command, {"NICK", [Nick]}}, #state{sock=Sock,
client=Client} = State) ->
    send_command(Sock, {"NICK", [Nick]}),
    dict_proc:store(nick, Nick, Client),
    {noreply, State};
handle_cast({irc_send_command, Command}, #state{sock=Sock} = State) ->
	io:format("trace: handle_cast"),
    send_command(Sock, Command),
    {noreply, State}.

send_client_command(Irclib, Command, Args) ->
	io:format("trace: irc_lib.invoke cast(1) {{ ~p ~p }}~n", [Command, Args]), 
    gen_server:cast(Irclib, {irc_send_command, {Command, Args}}).

send_client_command(Irclib, Command) ->
	io:format("trace: irc_lib.invoke cast(2)"), 
    gen_server:cast(Irclib, {irc_send_command, {Command}}).

% Functions used to send various command sto the client
pong(Irclib, Server) ->
    send_client_command(Irclib, "PONG", [Server]).

ping(Irclib) ->
    send_client_command(Irclib, "PING").

whois(Irclib, Who) ->
    send_client_command(Irclib, "WHOIS", [Who]).

join(Irclib, {Channel, Pass}) ->
	io:format("trace: join(a)@~p~n", [Channel]),
    send_client_command(Irclib, "JOIN", [Channel, Pass]);
join(Irclib, Channel) when list(Channel) ->
	io:format("trace: join@~p~n", [Channel]),
	%% TODO: remove test code
    send_client_command(Irclib, "JOIN").


http://openbotlist.googlecode.com/svn/trunk/botlistprojects/laughingman/orbirclib/src/irc_lib.erl



--
Berlin Brown
email: berlin-dot-brown-AT-gmail-dot-com
http://botspiritcompany.com/botlist/




More information about the erlang-questions mailing list