25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Fix problem with c2s buffering on old style websocket connections

Old style websocket do use binaries for transferring data to C2S, so when
we buffer that data we need to handle it different than list of #xml structs
used by new style connections.

This fixes github issue #515.
This commit is contained in:
Paweł Chmielowski 2015-04-06 17:54:45 +02:00
parent 64978b3d9c
commit 81b0643036

View File

@ -138,7 +138,9 @@ handle_event({activate, From}, StateName, StateData) ->
StateData#state{waiting_input = From}}; StateData#state{waiting_input = From}};
Input -> Input ->
Receiver = From, Receiver = From,
Receiver ! {tcp, StateData#state.socket, Input}, lists:foreach(fun(I) ->
Receiver ! {tcp, StateData#state.socket, I}
end, Input),
{next_state, StateName, {next_state, StateName,
StateData#state{input = [], waiting_input = false, StateData#state{input = [], waiting_input = false,
last_receiver = Receiver}} last_receiver = Receiver}}
@ -209,7 +211,7 @@ handle_info({received, Packet}, StateName, StateDataI) ->
{StateData, Parsed} = parse(StateDataI, Packet), {StateData, Parsed} = parse(StateDataI, Packet),
SD = case StateData#state.waiting_input of SD = case StateData#state.waiting_input of
false -> false ->
Input = StateData#state.input ++ Parsed, Input = StateData#state.input ++ if is_binary(Parsed) -> [Parsed]; true -> Parsed end,
StateData#state{input = Input}; StateData#state{input = Input};
Receiver -> Receiver ->
Receiver ! {tcp, StateData#state.socket, Parsed}, Receiver ! {tcp, StateData#state.socket, Parsed},