Skip to content

Commit

Permalink
guid for a session was not used anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
majek committed Feb 24, 2012
1 parent 8dd06af commit dbc5538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/sockjs_session.erl
Expand Up @@ -24,7 +24,7 @@
handle :: handle()}). handle :: handle()}).
-define(ETS, sockjs_table). -define(ETS, sockjs_table).


-type(handle() :: {?MODULE, {binary(), pid()}}). -type(handle() :: {?MODULE, pid()}).


-include("sockjs_internal.hrl"). -include("sockjs_internal.hrl").


Expand Down Expand Up @@ -63,12 +63,12 @@ received(Messages, SessionId) ->
received(Messages, spid(SessionId)). received(Messages, spid(SessionId)).


-spec send(iodata(), handle()) -> ok. -spec send(iodata(), handle()) -> ok.
send(Data, {?MODULE, {_, SPid}}) -> send(Data, {?MODULE, SPid}) ->
gen_server:cast(SPid, {send, Data}), gen_server:cast(SPid, {send, Data}),
ok. ok.


-spec close(non_neg_integer(), string(), handle()) -> ok. -spec close(non_neg_integer(), string(), handle()) -> ok.
close(Code, Reason, {?MODULE, {_, SPid}}) -> close(Code, Reason, {?MODULE, SPid}) ->
gen_server:cast(SPid, {close, Code, Reason}), gen_server:cast(SPid, {close, Code, Reason}),
ok. ok.


Expand Down Expand Up @@ -172,7 +172,7 @@ init({SessionId, #service{callback = Callback,
disconnect_delay = DisconnectDelay, disconnect_delay = DisconnectDelay,
heartbeat_tref = undefined, heartbeat_tref = undefined,
heartbeat_delay = HeartbeatDelay, heartbeat_delay = HeartbeatDelay,
handle = {?MODULE, {sockjs_util:guid(), self()}}}}. handle = {?MODULE, self()}}}.




handle_call({reply, Pid, _Multiple}, _From, State = #session{ handle_call({reply, Pid, _Multiple}, _From, State = #session{
Expand Down
17 changes: 0 additions & 17 deletions src/sockjs_util.erl
@@ -1,7 +1,6 @@
-module(sockjs_util). -module(sockjs_util).


-export([rand32/0]). -export([rand32/0]).
-export([guid/0]).
-export([encode_frame/1]). -export([encode_frame/1]).
-export([url_escape/2]). -export([url_escape/2]).


Expand All @@ -21,22 +20,6 @@ rand32() ->
end, end,
random:uniform(erlang:trunc(math:pow(2,32)))-1. random:uniform(erlang:trunc(math:pow(2,32)))-1.


-spec guid() -> binary().
guid() ->
list_to_binary(
safe_encode(
erlang:md5(
term_to_binary({rand32(), rand32(), rand32(), rand32()})
))).

safe_encode(Binary) ->
Base64 = base64:encode_to_string(Binary),
%% Replace '+' and '/' if necessary
lists:map(fun ($/) -> $-;
($+) -> $_;
(C) -> C
end, Base64).



-spec encode_frame(frame()) -> iodata(). -spec encode_frame(frame()) -> iodata().
encode_frame({open, nil}) -> encode_frame({open, nil}) ->
Expand Down

0 comments on commit dbc5538

Please sign in to comment.