25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

* src/ejabberd_c2s.erl: Bugfix in processing of connection

replacement

SVN Revision: 180
This commit is contained in:
Alexey Shchepin 2003-12-02 20:20:53 +00:00
parent 48e8a0c0c6
commit 83a0be1009
2 changed files with 38 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2003-12-02 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_c2s.erl: Bugfix in processing of connection
replacement
2003-11-28 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_c2s.erl: Added workaround for some Java clients

View File

@ -676,7 +676,7 @@ handle_info({send_text, Text}, StateName, StateData) ->
handle_info(replaced, StateName, StateData) ->
% TODO
%send_text(StateData#state.sender, Text),
{stop, normal, StateData#state{user = ""}};
{stop, normal, StateData#state{authentificated = replaced}};
handle_info({route, From, To, Packet}, StateName, StateData) ->
{xmlelement, Name, Attrs, Els} = Packet,
{Pass, NewAttrs, NewState} =
@ -811,17 +811,38 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
terminate(Reason, StateName, StateData) ->
case StateName of
session_established ->
?INFO_MSG("(~w) Close session for ~s",
[StateData#state.socket,
jlib:jid_to_string(StateData#state.jid)]),
ejabberd_sm:close_session(StateData#state.user,
StateData#state.resource),
From = StateData#state.jid,
Packet = {xmlelement, "presence", [{"type", "unavailable"}], []},
ejabberd_sm:unset_presence(StateData#state.user,
StateData#state.resource),
presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
presence_broadcast(StateData, From, StateData#state.pres_i, Packet);
case StateData#state.authentificated of
replaced ->
?INFO_MSG("(~w) Replaced session for ~s",
[StateData#state.socket,
jlib:jid_to_string(StateData#state.jid)]),
From = StateData#state.jid,
Packet = {xmlelement, "presence",
[{"type", "unavailable"}],
[{xmlelement, "status", [],
[{xmlcdata, "Replaced by new connection"}]}]},
ejabberd_sm:unset_presence(StateData#state.user,
StateData#state.resource),
presence_broadcast(
StateData, From, StateData#state.pres_a, Packet),
presence_broadcast(
StateData, From, StateData#state.pres_i, Packet);
_ ->
?INFO_MSG("(~w) Close session for ~s",
[StateData#state.socket,
jlib:jid_to_string(StateData#state.jid)]),
ejabberd_sm:close_session(StateData#state.user,
StateData#state.resource),
From = StateData#state.jid,
Packet = {xmlelement, "presence",
[{"type", "unavailable"}], []},
ejabberd_sm:unset_presence(StateData#state.user,
StateData#state.resource),
presence_broadcast(
StateData, From, StateData#state.pres_a, Packet),
presence_broadcast(
StateData, From, StateData#state.pres_i, Packet)
end;
_ ->
ok
end,