Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ compile: deps
test: force
@./rebar eunit skip_deps=true

force:
force:
@true
6 changes: 3 additions & 3 deletions demo/demo.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env escript
%%! -pa ../ebin ../deps/misultin/ebin ../deps/ossp_uuid/ebin ../deps/jsx/ebin
%%! -pa ../ebin ../deps/misultin/ebin ../deps/ossp_uuid/ebin ../deps/jsx/ebin
-mode(compile).
-include_lib("../include/socketio.hrl").
-compile(export_all).
Expand All @@ -14,9 +14,9 @@ main(_) ->
application:start(sasl),
application:start(misultin),
application:start(socketio),
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{default_http_handler,?MODULE}]),
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{default_http_handler,?MODULE}]),
EventMgr = socketio_listener:event_manager(Pid),
ok = gen_event:add_handler(EventMgr, ?MODULE,[]),
Expand Down
6 changes: 3 additions & 3 deletions demo/demo_ssl.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env escript
%%! -pa ../ebin ../deps/misultin/ebin ../deps/ossp_uuid/ebin ../deps/jsx/ebin
%%! -pa ../ebin ../deps/misultin/ebin ../deps/ossp_uuid/ebin ../deps/jsx/ebin
-mode(compile).
-include_lib("../include/socketio.hrl").
-compile(export_all).
Expand All @@ -8,13 +8,13 @@
%% gen_event callbacks
-export([init/1, handle_event/2, handle_call/2, handle_info/2,
terminate/2, code_change/3]).

main(_) ->
appmon:start(),
application:start(sasl),
application:start(misultin),
application:start(socketio),
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{ok, Pid} = socketio_listener:start([{http_port, 7878},
{default_http_handler,?MODULE},
{ssl, [
{certfile, "test_certificate.pem"},
Expand Down
2 changes: 1 addition & 1 deletion src/socketio_client_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ start_link() ->

init([]) ->
{ok, { {simple_one_for_one, 5, 10}, [
{socketio_client, {socketio_client, start_link, []},
{socketio_client, {socketio_client, start_link, []},
transient, 5000, worker, [socketio_client]}
]} }.

2 changes: 1 addition & 1 deletion src/socketio_data_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

%% Framing is only given when no other suitable mode exists. In this case,
%% XHR-multipart will already frame these.
%% It is not defined whether we should
%% It is not defined whether we should
-define(FRAME, 16#fffd).
-define(BINFRAME, <<65533>>).
-define(RESERVED_EVENTS, [<<"message">>, <<"connect">>, <<"disconnect">>,
Expand Down
46 changes: 23 additions & 23 deletions src/socketio_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-define(SERVER, ?MODULE).
-define(SERVER, ?MODULE).

-record(state, {
default_http_handler,
Expand Down Expand Up @@ -81,7 +81,7 @@ init([ServerModule, Port, Resource, SSL, DefaultHttpHandler, Sup]) ->
%% {stop, Reason, State}
%% @end
%%--------------------------------------------------------------------
handle_call({request, 'GET', ["socket.io.js"|Resource], Req}, _From, #state{ server_module = ServerModule,
handle_call({request, 'GET', ["socket.io.js"|Resource], Req}, _From, #state{ server_module = ServerModule,
resource = Resource } = State) ->
Response = apply(ServerModule, file, [Req, filename:join([filename:dirname(code:which(?MODULE)), "..", "priv", "Socket.IO", "socket.io.js"])]),
{reply, Response, State};
Expand All @@ -96,24 +96,24 @@ handle_call({request, 'GET', [_Random, "xhr-polling"|Resource], Req }, From, #st
handle_call({session, generate, {'xhr-polling', Req}, socketio_transport_polling}, From, State);

%% Returning XHR Polling
handle_call({request, 'GET', [_Random, SessionId, "xhr-polling"|Resource], Req }, From,
handle_call({request, 'GET', [_Random, SessionId, "xhr-polling"|Resource], Req }, From,
#state{ server_module = ServerModule,
resource = Resource, sessions = Sessions } = State) ->
case ets:lookup(Sessions, SessionId) of
[{SessionId, Pid}] ->
[{SessionId, Pid}] ->
gen_server:cast(Pid, {'xhr-polling', polling_request, Req, From});
_ ->
gen_server:reply(From, apply(ServerModule, respond, [Req, 404, ""]))
end,
{noreply, State};

%% Incoming XHR Polling data
handle_call({request, 'POST', ["send", SessionId, "xhr-polling"|Resource], Req }, _From, #state{ resource = Resource,
handle_call({request, 'POST', ["send", SessionId, "xhr-polling"|Resource], Req }, _From, #state{ resource = Resource,
server_module = ServerModule,
sessions = Sessions } = State) ->
Response =
Response =
case ets:lookup(Sessions, SessionId) of
[{SessionId, Pid}] ->
[{SessionId, Pid}] ->
gen_server:call(Pid, {'xhr-polling', data, Req});
_ ->
apply(ServerModule, respond, [Req, 404, ""])
Expand All @@ -125,8 +125,8 @@ handle_call({request, 'GET', [Index, _Random, "jsonp-polling"|Resource], Req },
handle_call({session, generate, {'jsonp-polling', {Req, Index}}, socketio_transport_polling}, From, State);

%% Returning JSONP Polling
handle_call({request, 'GET', [Index, _Random, SessionId, "jsonp-polling"|Resource], Req }, From,
#state{ resource = Resource,
handle_call({request, 'GET', [Index, _Random, SessionId, "jsonp-polling"|Resource], Req }, From,
#state{ resource = Resource,
server_module = ServerModule,
sessions = Sessions } = State) ->
case ets:lookup(Sessions, SessionId) of
Expand All @@ -138,13 +138,13 @@ handle_call({request, 'GET', [Index, _Random, SessionId, "jsonp-polling"|Resourc
{noreply, State};

%% Incoming JSONP Polling data
handle_call({request, 'POST', [_Index, _Random, SessionId, "jsonp-polling"|Resource], Req }, _From,
#state{ resource = Resource,
handle_call({request, 'POST', [_Index, _Random, SessionId, "jsonp-polling"|Resource], Req }, _From,
#state{ resource = Resource,
server_module = ServerModule,
sessions = Sessions } = State) ->
Response =
Response =
case ets:lookup(Sessions, SessionId) of
[{SessionId, Pid}] ->
[{SessionId, Pid}] ->
gen_server:call(Pid, {'jsonp-polling', data, Req});
_ ->
apply(ServerModule, respond, [Req, 404, ""])
Expand All @@ -157,13 +157,13 @@ handle_call({request, 'GET', ["xhr-multipart"|Resource], Req }, From, #state{ re
{noreply, State};

%% Incoming XHR Multipart data
handle_call({request, 'POST', ["send", SessionId, "xhr-multipart"|Resource], Req }, _From,
#state{ resource = Resource,
handle_call({request, 'POST', ["send", SessionId, "xhr-multipart"|Resource], Req }, _From,
#state{ resource = Resource,
server_module = ServerModule,
sessions = Sessions } = State) ->
Response =
Response =
case ets:lookup(Sessions, SessionId) of
[{SessionId, Pid}] ->
[{SessionId, Pid}] ->
gen_server:call(Pid, {'xhr-multipart', data, Req});
_ ->
apply(ServerModule, respond, [Req, 404, ""])
Expand All @@ -177,13 +177,13 @@ handle_call({request, 'GET', [_Random, "htmlfile"|Resource], Req }, From, #state
{noreply, State};

%% Incoming htmlfile data
handle_call({request, 'POST', ["send", SessionId, "htmlfile"|Resource], Req }, _From,
#state{ resource = Resource,
handle_call({request, 'POST', ["send", SessionId, "htmlfile"|Resource], Req }, _From,
#state{ resource = Resource,
server_module = ServerModule,
sessions = Sessions } = State) ->
Response =
Response =
case ets:lookup(Sessions, SessionId) of
[{SessionId, Pid}] ->
[{SessionId, Pid}] ->
gen_server:call(Pid, {'htmlfile', data, Req});
_ ->
apply(ServerModule, respond, [Req, 404, ""])
Expand All @@ -202,7 +202,7 @@ handle_call({request, Method, Path, Req}, _From, #state{ default_http_handler =
{reply, Response, State};

%% Sessions
handle_call({session, generate, ConnectionReference, Transport}, _From, #state{
handle_call({session, generate, ConnectionReference, Transport}, _From, #state{
sup = Sup,
sessions = Sessions,
event_manager = EventManager,
Expand Down Expand Up @@ -260,7 +260,7 @@ handle_info({'EXIT', Pid, _}, #state{ event_manager = EventManager, sessions = S

% If misultin goes down, we stop socket.io
handle_info({'DOWN', WebServerRef, _, _, _}, #state{ web_server_monitor = WebServerRef } = State) ->
{stop, normal, State};
{stop, normal, State};

handle_info(_Info, State) ->
{noreply, State}.
Expand Down
2 changes: 1 addition & 1 deletion src/socketio_http_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ start_link() ->

init([]) ->
{ok, { {simple_one_for_one, 5, 10}, [
{socketio_http, {socketio_http, start_link, []},
{socketio_http, {socketio_http, start_link, []},
permanent, 5000, worker, [socketio_http]}
]} }.

2 changes: 1 addition & 1 deletion src/socketio_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ handle_call(origins, _From, #state{ origins = Origins } = State) ->

handle_call({origins, Origins}, _From,State) ->
{reply, Origins, State#state{ origins = Origins }};

%% Event management
handle_call(event_manager, _From, #state{ sup = Sup } = State) ->
Children = supervisor:which_children(Sup),
Expand Down
4 changes: 2 additions & 2 deletions src/socketio_listener_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ init([Options]) ->
Resource,
SSL,
DefaultHttpHandler,
self()]},
self()]},
permanent, 5000, worker, [socketio_http]},

{socketio_client_sup, {socketio_client_sup, start_link, []},
{socketio_client_sup, {socketio_client_sup, start_link, []},
permanent, infinity, supervisor, [socketio_client_sup]}

]} }.
Expand Down
2 changes: 1 addition & 1 deletion src/socketio_listener_sup_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ start_link() ->

init([]) ->
{ok, { {simple_one_for_one, 5, 10}, [
{socketio_listener_sup, {socketio_listener_sup, start_link, []},
{socketio_listener_sup, {socketio_listener_sup, start_link, []},
permanent, infinity, supervisor, [socketio_listener_sup]}
]} }.

2 changes: 1 addition & 1 deletion src/socketio_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ start_link() ->

init([]) ->
{ok, { {one_for_one, 5, 10}, [
{socketio_listener_sup_sup, {socketio_listener_sup_sup, start_link, []},
{socketio_listener_sup_sup, {socketio_listener_sup_sup, start_link, []},
permanent, infinity, supervisor, [socketio_listener_sup_sup]}

]} }.
Expand Down
8 changes: 4 additions & 4 deletions src/socketio_transport_htmlfile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-define(SERVER, ?MODULE).
-define(SERVER, ?MODULE).

-record(state, {
session_id,
Expand Down Expand Up @@ -56,7 +56,7 @@ start_link(Sup, SessionId, ServerModule, ConnectionReference) ->
init([Sup, SessionId, ServerModule, {'htmlfile', {Req, Caller}}]) ->
apply(ServerModule, ensure_longpolling_request, [Req]),
process_flag(trap_exit, true),
HeartbeatInterval =
HeartbeatInterval =
case application:get_env(heartbeat_interval) of
{ok, Time} ->
Time;
Expand All @@ -67,7 +67,7 @@ init([Sup, SessionId, ServerModule, {'htmlfile', {Req, Caller}}]) ->
),
10000
end,
CloseTimeout =
CloseTimeout =
case application:get_env(close_timeout) of
{ok, Time0} ->
Time0;
Expand Down Expand Up @@ -169,7 +169,7 @@ handle_cast(heartbeat, #state{ heartbeats = Beats,
heartbeat_interval = reset_heartbeat(Interval) }};

%% Send
handle_cast({send, Message}, #state{ req = Req,
handle_cast({send, Message}, #state{ req = Req,
server_module = ServerModule,
connection_reference = {'htmlfile', connected },
heartbeat_interval = Interval } = State) ->
Expand Down
8 changes: 4 additions & 4 deletions src/socketio_transport_polling.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-define(SERVER, ?MODULE).
-define(SERVER, ?MODULE).

-record(state, {
session_id,
Expand Down Expand Up @@ -56,7 +56,7 @@ start_link(Sup, SessionId, ServerModule, ConnectionReference) ->
%%--------------------------------------------------------------------
init([Sup, SessionId, ServerModule, {TransportType, {Req, Index}}]) ->
process_flag(trap_exit, true),
PollingDuration =
PollingDuration =
case application:get_env(polling_duration) of
{ok, Time} ->
Time;
Expand All @@ -67,7 +67,7 @@ init([Sup, SessionId, ServerModule, {TransportType, {Req, Index}}]) ->
),
20000
end,
CloseTimeout =
CloseTimeout =
case application:get_env(close_timeout) of
{ok, Time0} ->
Time0;
Expand Down Expand Up @@ -174,7 +174,7 @@ handle_cast({TransportType, polling_request, Req, Server}, #state { server_modul
caller = Server,
polling_duration = reset_duration(Interval) }};

handle_cast({TransportType, polling_request, Req, Server}, #state { server_module = ServerModule,
handle_cast({TransportType, polling_request, Req, Server}, #state { server_module = ServerModule,
message_buffer = Buffer } = State) ->
link(ServerModule:socket(Req)),
handle_cast({send, {buffer, Buffer}}, State#state{ connection_reference = {TransportType, connected},
Expand Down
6 changes: 3 additions & 3 deletions src/socketio_transport_websocket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-define(SERVER, ?MODULE).
-define(SERVER, ?MODULE).

-record(state, {
session_id,
Expand Down Expand Up @@ -52,7 +52,7 @@ start_link(Sup, SessionId, ServerModule, ConnectionReference) ->
%% @end
%%--------------------------------------------------------------------
init([Sup, SessionId, ServerModule, ConnectionReference]) ->
HeartbeatInterval =
HeartbeatInterval =
case application:get_env(heartbeat_interval) of
{ok, Time} ->
Time;
Expand Down Expand Up @@ -142,7 +142,7 @@ handle_cast({send, Message}, #state{ server_module = ServerModule,
handle_send(ConnectionReference, Message, ServerModule),
{noreply, State#state{ heartbeat_interval = reset_interval(Interval) }};

handle_cast(heartbeat, #state{
handle_cast(heartbeat, #state{
server_module = ServerModule,
connection_reference = ConnectionReference, heartbeats = Beats,
heartbeat_interval = Interval } = State) ->
Expand Down
8 changes: 4 additions & 4 deletions src/socketio_transport_xhr_multipart.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-define(SERVER, ?MODULE).
-define(SERVER, ?MODULE).

-record(state, {
session_id,
Expand Down Expand Up @@ -56,7 +56,7 @@ start_link(Sup, SessionId, ServerModule, ConnectionReference) ->
init([Sup, SessionId, ServerModule, {'xhr-multipart', {Req, Caller}}]) ->
apply(ServerModule, ensure_longpolling_request, [Req]),
process_flag(trap_exit, true),
HeartbeatInterval =
HeartbeatInterval =
case application:get_env(heartbeat_interval) of
{ok, Time} ->
Time;
Expand All @@ -67,7 +67,7 @@ init([Sup, SessionId, ServerModule, {'xhr-multipart', {Req, Caller}}]) ->
),
10000
end,
CloseTimeout =
CloseTimeout =
case application:get_env(close_timeout) of
{ok, Time0} ->
Time0;
Expand Down Expand Up @@ -185,7 +185,7 @@ handle_cast(heartbeat, #state{ heartbeats = Beats,
heartbeat_interval = reset_heartbeat(Interval) }};

%% Send
handle_cast({send, Message}, #state{ req = Req,
handle_cast({send, Message}, #state{ req = Req,
server_module = ServerModule,
connection_reference = {'xhr-multipart', connected },
heartbeat_interval = Interval } = State) ->
Expand Down
Loading