Permalink
Browse files

catch nosession error when got some data in ws

  • Loading branch information...
1 parent 75ea352 commit 0c70e1ce635bf23ed89044b79f447d5cc0cf4ac4 @majek majek committed Feb 14, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/sockjs_ws_handler.erl
View
@@ -13,17 +13,22 @@ received(_RawWebsocket, _SessionPid, <<>>) ->
received(websocket, SessionPid, Data) ->
case sockjs_json:decode(Data) of
{ok, Msg} when is_binary(Msg) ->
- sockjs_session:received([Msg], SessionPid),
- ok;
+ session_received([Msg], SessionPid);
{ok, Messages} when is_list(Messages) ->
- sockjs_session:received(Messages, SessionPid),
- ok;
+ session_received(Messages, SessionPid);
_Else ->
shutdown
end;
received(rawwebsocket, SessionPid, Data) ->
- sockjs_session:received([Data], SessionPid).
+ session_received([Data], SessionPid).
+
+session_received(Messages, SessionPid) ->
+ try sockjs_session:received(Messages, SessionPid) of
+ ok -> ok
+ catch
+ no_session -> shutdown
+ end.
-spec reply(websocket|rawwebsocket, pid()) -> {close|open, binary()} | wait.
reply(websocket, SessionPid) ->

0 comments on commit 0c70e1c

Please sign in to comment.