Permalink
Browse files

General cleanup & refactored login/logout so that they connect discon…

…nect on success
  • Loading branch information...
1 parent fedd659 commit 42dbba798436bf3d3730e2ca71504e6da74be496 @baphled committed Apr 8, 2009
Showing with 10 additions and 6 deletions.
  1. +6 −2 lib/chatterl/src/chatterl_mid_man.erl
  2. +4 −4 lib/chatterl/src/cwiga.erl
@@ -87,7 +87,9 @@ login(ContentType,{Client,Password}) ->
{Type,Reply} =
case chatterl_serv:login(Client,Password) of
{error,Error} -> {"failure",Error};
- {ok,Msg} -> {"success",Msg}
+ {ok,Msg} ->
+ gen_server:call({global, ?SERVER}, {connect, Client},infinity),
+ {"success",Msg}
end,
get_response_body(ContentType,build_carrier(Type,Reply)).
@@ -101,7 +103,9 @@ logout(ContentType,Client) ->
{Type,Reply} =
case chatterl_serv:logout(Client) of
{error,Error} -> {"failure",Error};
- {ok,Msg} -> {"success",Msg}
+ {ok,Msg} ->
+ gen_server:call({global, ?SERVER}, {disconnect, Client},infinity),
+ {"success",Msg}
end,
get_response_body(ContentType,build_carrier(Type,Reply)).
@@ -188,16 +188,16 @@ handle_request('GET', Url, ContentType, Req) ->
case Path of
["users"] ->
manage_request(ContentType,Req,{user_list,[]},false);
- ["users",Client,"connect"] ->
- chatterl_mid_man:connect(ContentType,Client);
+ ["groups"] ->
+ manage_request(ContentType,Req,{group_list,[]},false);
["users",Group,"users"] ->
manage_request(ContentType,Req,{user_list,Group},false);
+ ["users",Client,"connect"] ->
+ chatterl_mid_man:connect(ContentType,Client);
["users",Client,"poll"] ->
manage_request(ContentType,Req,{user_poll,Client},false);
["users",Client,"groups"] ->
manage_request(ContentType,Req,{user_groups,Client},true);
- ["groups"] ->
- manage_request(ContentType,Req,{group_list,[]},false);
["groups",Group,"info"] ->
manage_request(ContentType,Req,{group_info,Group},false);
["groups",Group,"poll"] ->

0 comments on commit 42dbba7

Please sign in to comment.