Skip to content
This repository
Browse code

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

… an atom
  • Loading branch information...
commit 0ed0e25564b0a4b07fa2fea01b915bc569179ea4 1 parent 0305a29
Yomi Colledge authored January 14, 2009
6  lib/chatterl/src/chatterl_gateway.erl
@@ -317,11 +317,13 @@ generate_record(Group,Payload,Client) ->
317 317
 			    build_carrier("failure",Error)
318 318
 		    end;
319 319
 		{group_msg,Message} ->
  320
+		    %% Need to check that the user is connected to the group.
320 321
 		    case gen_server:call({global,Group},{send_msg,Client,Message}, infinity) of
321 322
 			{ok,Msg} -> 
  323
+			    io:format(Msg),
322 324
 			    build_carrier("success",atom_to_list(Msg));
323  
-			{error,Error} ->
324  
-			    build_carrier("failure",Error)
  325
+			{error,_Error} ->
  326
+			    build_carrier("failure","Can not send the same message twice")
325 327
 		    end;
326 328
 		_ -> io:format("Unrecognised payload: ~s~n",[Payload])
327 329
 			end;
15  lib/chatterl/src/chatterl_groups.erl
@@ -188,12 +188,13 @@ handle_info(Info, State) ->
188 188
 terminate(Reason, State) ->
189 189
     case gb_trees:is_empty(State#group.users) of
190 190
 	false ->
191  
-	    determine_user_action(State#group.name,{drop_group,[]},
192  
-				  gb_trees:values(State#group.users));
  191
+	    %determine_user_action(State#group.name,{drop_group,[]},
  192
+		%		  gb_trees:values(State#group.users));
  193
+	    ok;
193 194
 	true ->
194 195
 	    io:format("No users to inform of shutdown~n")
195 196
     end,
196  
-    gen_server:call({global,chatterl_serv}, {drop_group,State#group.name},infinity),
  197
+    gen_server:call({global,chatterl_serv}, {drop_group,State#group.name}),
197 198
     io:format("Shutdown ~s:~nReason:~s~n",[State#group.name,Reason]),
198 199
     {shutdown, State#group.name}.
199 200
 
@@ -229,8 +230,8 @@ determine_user_action(GroupName,{Action,PayLoad},UsersList) ->
229 230
 	receive_msg ->
230 231
 	    case PayLoad of
231 232
 		{CreatedOn,Sender,Message} ->
232  
-		    GroupMsg = "Sending to users ~s~n";
233  
-		    %send_msg_to_users({receive_msg, CreatedOn,Sender,Message},UsersList,GroupMsg);
  233
+		    GroupMsg = "Sending to users ~s~n",
  234
+		    send_msg_to_users({receive_msg, CreatedOn,Sender,Message},UsersList,GroupMsg);
234 235
 		_ ->
235 236
 		    {error, "Illegal payload format"}
236 237
 	    end;
@@ -255,10 +256,10 @@ send_msg_to_users(PayLoad,UsersList,GroupMsg) ->
255 256
 				   {user_lookup, Client}, infinity) of
256 257
 		  {error, Error} ->
257 258
 		      io:format("Error: ~s~n",[Error]);
258  
-		  {ok, ClientName, ClientPid} ->
  259
+		  {ok, ClientName, _ClientPid} ->
259 260
 		      io:format(GroupMsg,
260 261
 				[ClientName]),
261  
-		      gen_server:call(ClientPid,PayLoad)
  262
+		      gen_server:call({global,ClientName},PayLoad,infinity)
262 263
 	      end
263 264
       end,
264 265
       UsersList).

0 notes on commit 0ed0e25

Please sign in to comment.
Something went wrong with that request. Please try again.