case Packet2 of
{xmlstreamstart, Name, Attrs3} ->
B = fxml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}),
- WsPid ! {send, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>};
+ WsPid ! {text, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>};
{xmlstreamend, Name} ->
- WsPid ! {send, <<"</", Name/binary, ">">>};
+ WsPid ! {text, <<"</", Name/binary, ">">>};
{xmlstreamelement, El} ->
- WsPid ! {send, fxml:element_to_binary(El)};
+ WsPid ! {text, fxml:element_to_binary(El)};
{xmlstreamraw, Bin} ->
- WsPid ! {send, Bin};
+ WsPid ! {text, Bin};
{xmlstreamcdata, Bin2} ->
- WsPid ! {send, Bin2};
+ WsPid ! {text, Bin2};
skip ->
ok
end,
when StateName /= stream_end_sent ->
Close = #xmlel{name = <<"close">>,
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
- WsPid ! {send, fxml:element_to_binary(Close)},
+ WsPid ! {text, fxml:element_to_binary(Close)},
{stop, normal, StateData};
handle_sync_event(close, _From, _StateName, StateData) ->
{stop, normal, StateData}.
end,
erlang:demonitor(Ref),
websocket_close(Socket, WsHandleLoopPid, SocketMode, Code);
- {send, Data} ->
+ {text, Data} ->
SocketMode:send(Socket, encode_frame(Data, 1)),
ws_loop(FrameInfo, Socket, WsHandleLoopPid,
SocketMode);
+ {data, Data} ->
+ SocketMode:send(Socket, encode_frame(Data, 2)),
+ ws_loop(FrameInfo, Socket, WsHandleLoopPid,
+ SocketMode);
{ping, Data} ->
SocketMode:send(Socket, encode_frame(Data, 9)),
ws_loop(FrameInfo, Socket, WsHandleLoopPid,
end.
handle_call({send, Data}, _From, #state{ws_pid = WsPid} = State) ->
- WsPid ! {send, Data},
+ WsPid ! {data, Data},
{reply, ok, State};
handle_call(Request, From, State) ->
?WARNING_MSG("Got unexpected call from ~p: ~p", [From, Request]),