Permalink
Browse files

Fixed a bug in group_msg catch in generate_record, was trying to pass…

… an atom
  • Loading branch information...
1 parent 0305a29 commit 0ed0e25564b0a4b07fa2fea01b915bc569179ea4 @baphled committed Jan 14, 2009
Showing with 12 additions and 9 deletions.
  1. +4 −2 lib/chatterl/src/chatterl_gateway.erl
  2. +8 −7 lib/chatterl/src/chatterl_groups.erl
@@ -317,11 +317,13 @@ generate_record(Group,Payload,Client) ->
build_carrier("failure",Error)
end;
{group_msg,Message} ->
+ %% Need to check that the user is connected to the group.
case gen_server:call({global,Group},{send_msg,Client,Message}, infinity) of
{ok,Msg} ->
+ io:format(Msg),
build_carrier("success",atom_to_list(Msg));
- {error,Error} ->
- build_carrier("failure",Error)
+ {error,_Error} ->
+ build_carrier("failure","Can not send the same message twice")
end;
_ -> io:format("Unrecognised payload: ~s~n",[Payload])
end;
@@ -188,12 +188,13 @@ handle_info(Info, State) ->
terminate(Reason, State) ->
case gb_trees:is_empty(State#group.users) of
false ->
- determine_user_action(State#group.name,{drop_group,[]},
- gb_trees:values(State#group.users));
+ %determine_user_action(State#group.name,{drop_group,[]},
+ % gb_trees:values(State#group.users));
+ ok;
true ->
io:format("No users to inform of shutdown~n")
end,
- gen_server:call({global,chatterl_serv}, {drop_group,State#group.name},infinity),
+ gen_server:call({global,chatterl_serv}, {drop_group,State#group.name}),
io:format("Shutdown ~s:~nReason:~s~n",[State#group.name,Reason]),
{shutdown, State#group.name}.
@@ -229,8 +230,8 @@ determine_user_action(GroupName,{Action,PayLoad},UsersList) ->
receive_msg ->
case PayLoad of
{CreatedOn,Sender,Message} ->
- GroupMsg = "Sending to users ~s~n";
- %send_msg_to_users({receive_msg, CreatedOn,Sender,Message},UsersList,GroupMsg);
+ GroupMsg = "Sending to users ~s~n",
+ send_msg_to_users({receive_msg, CreatedOn,Sender,Message},UsersList,GroupMsg);
_ ->
{error, "Illegal payload format"}
end;
@@ -255,10 +256,10 @@ send_msg_to_users(PayLoad,UsersList,GroupMsg) ->
{user_lookup, Client}, infinity) of
{error, Error} ->
io:format("Error: ~s~n",[Error]);
- {ok, ClientName, ClientPid} ->
+ {ok, ClientName, _ClientPid} ->
io:format(GroupMsg,
[ClientName]),
- gen_server:call(ClientPid,PayLoad)
+ gen_server:call({global,ClientName},PayLoad,infinity)
end
end,
UsersList).

0 comments on commit 0ed0e25

Please sign in to comment.