25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/ejabberd_c2s.erl: More correct stream closing

SVN Revision: 85
This commit is contained in:
Alexey Shchepin 2003-03-02 20:55:16 +00:00
parent d062175ffb
commit 658552d605
2 changed files with 20 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2003-03-02 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_c2s.erl: More correct stream closing
2003-02-27 Alexey Shchepin <alexey@sevcom.net> 2003-02-27 Alexey Shchepin <alexey@sevcom.net>
* src/mod_irc/mod_irc_connection.erl: Support for topic changes * src/mod_irc/mod_irc_connection.erl: Support for topic changes

View File

@ -58,6 +58,8 @@
-define(STREAM_TRAILER, "</stream:stream>"). -define(STREAM_TRAILER, "</stream:stream>").
-define(INVALID_NS_ERR, "<stream:error>Invalid Namespace</stream:error>"). -define(INVALID_NS_ERR, "<stream:error>Invalid Namespace</stream:error>").
-define(INVALID_XML_ERR,
"<stream:error code='400'>Invalid XML</stream:error>").
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
@ -113,6 +115,10 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
{stop, normal, StateData} {stop, normal, StateData}
end; end;
wait_for_stream({xmlstreamerror, _}, StateData) ->
send_text(StateData#state.socket, ?INVALID_XML_ERR),
{stop, normal, StateData};
wait_for_stream(closed, StateData) -> wait_for_stream(closed, StateData) ->
{stop, normal, StateData}. {stop, normal, StateData}.
@ -170,7 +176,11 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
end; end;
wait_for_auth({xmlstreamend, Name}, StateData) -> wait_for_auth({xmlstreamend, Name}, StateData) ->
% TODO send_text(StateData#state.socket, ?STREAM_TRAILER),
{stop, normal, StateData};
wait_for_auth({xmlstreamerror, _}, StateData) ->
send_text(StateData#state.socket, ?INVALID_XML_ERR ?STREAM_TRAILER),
{stop, normal, StateData}; {stop, normal, StateData};
wait_for_auth(closed, StateData) -> wait_for_auth(closed, StateData) ->
@ -213,10 +223,14 @@ session_established({xmlstreamelement, El}, StateData) ->
{next_state, session_established, NewState}; {next_state, session_established, NewState};
session_established({xmlstreamend, Name}, StateData) -> session_established({xmlstreamend, Name}, StateData) ->
send_text(StateData#state.socket, ?STREAM_TRAILER),
{stop, normal, StateData};
session_established({xmlstreamerror, _}, StateData) ->
send_text(StateData#state.socket, ?INVALID_XML_ERR ?STREAM_TRAILER),
{stop, normal, StateData}; {stop, normal, StateData};
session_established(closed, StateData) -> session_established(closed, StateData) ->
% TODO
{stop, normal, StateData}. {stop, normal, StateData}.