Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added session id to sockjs websocket connections

  • Loading branch information...
commit 9c14c5c0317c756015364812a43da561f54717b3 1 parent fb32ebb
@sridatta sridatta authored
Showing with 6 additions and 6 deletions.
  1. +2 −2 src/sockjs_cowboy_handler.erl
  2. +4 −4 src/sockjs_ws.erl
View
4 src/sockjs_cowboy_handler.erl
@@ -33,8 +33,8 @@ terminate(_Req, _State) ->
%% --------------------------------------------------------------------------
websocket_init(_TransportName, Req, {_Handler, WsHandler}) ->
- {Receive, {cowboy, Req1}} = WsHandler({cowboy, Req}),
- Self = {?WS_MODULE, self(), cowboy},
+ {Receive, {cowboy, Req1}, SessionId} = WsHandler({cowboy, Req}),
+ Self = {?WS_MODULE, self(), cowboy, SessionId},
self() ! {send, ["o"]},
Receive(Self, init),
{ok, Req1, #ws_state{self = Self, recv = Receive}}.
View
8 src/sockjs_ws.erl
@@ -7,17 +7,17 @@
%% TODO this has little in common with the other transports
%% Where should framing happen? (Do we care?)
-send(Data, {?MODULE, Ws, cowboy}) ->
+send(Data, {?MODULE, Ws, cowboy, _}) ->
Ws ! {send, ["a[", sockjs_util:encode(Data), "]"]};
-send(Data, {?MODULE, Ws, misultin}) ->
+send(Data, {?MODULE, Ws, misultin, _}) ->
Ws:send(["a[", sockjs_util:encode(Data), "]"]).
-close(Code, Reason, {?MODULE, Ws, cowboy}) ->
+close(Code, Reason, {?MODULE, Ws, cowboy, _}) ->
Ws ! {send, ["c", sockjs_util:encode([Code, list_to_binary(Reason)])]},
Ws ! shutdown;
-close(Code, Reason, {?MODULE, Ws, misultin}) ->
+close(Code, Reason, {?MODULE, Ws, misultin, _}) ->
Ws:send(["c", sockjs_util:encode([Code, list_to_binary(Reason)])]),
exit(normal). %% TODO ?
Please sign in to comment.
Something went wrong with that request. Please try again.