Skip to content

Commit

Permalink
Moving gproc user registration to the irc_server_fsm process.
Browse files Browse the repository at this point in the history
XXX - does this need to move to its own irc_user process?
  • Loading branch information
archaelus committed Dec 2, 2007
1 parent f6a67b2 commit cfbfcd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/gen_irc_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ handle_call({nick, Pid, Nick, Pass}, _From, S = #state{net=Net})
undefined ->
case modapply(handle_nick, [Nick, Pass], S) of
{nick_ok, NewMS} ->
true = gproc:reg(GprocUserName, self()),
{reply, ok, S#state{mod_state=NewMS}};
{reply, {ok, GprocUserName}, S#state{mod_state=NewMS}};
E = {error, _N, _Reason} ->
{reply, E, S}
end;
Expand Down
7 changes: 5 additions & 2 deletions src/irc_server_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ login_nick({irc, _, #irc_cmd{name=nick, args=Args}},
S = #state{server_mod=M, user=U}) ->
Name = proplists:get_value(name, Args),
case M:nick(S#state.server, Name, S#state.pass) of
ok ->
{ok, GprocUserName} ->
true = gproc:reg(GprocUserName, self()),
{next_state, login_user, S#state{user=U#user{nick=Name}}};
{error, Numeric, Reason} ->
numreply(S, Numeric, Reason),
Expand Down Expand Up @@ -134,8 +135,10 @@ welcome(State) ->
%serversend(State, #irc_cmd{name=isupport}), % XXX probably need to ask parent server what we support
{next_state, connected, State}.

connected(Event, State) ->
connected({irc, _, #irc_cmd{name=Cmd}} = Event, State) ->
?INFO("Got ~p in state connected.", [Event]),
serversend(State, #irc_cmd{name=unknowncommand,
args=[{command, Cmd}, {message, "Ye cannot do that here."}]}),
{next_state, connected, State}.

%%--------------------------------------------------------------------
Expand Down

0 comments on commit cfbfcd6

Please sign in to comment.