Skip to content

Commit 1c1aced

Browse files
committed
init commit
0 parents  commit 1c1aced

File tree

11 files changed

+400
-0
lines changed

11 files changed

+400
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
erl_crash.dump
2+
log/*
3+
ebin/*
4+
.eunit/
5+
deps

include/searcher.hrl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-define(MULTICAST_GROUP, {239,255,255,250}).
2+
-define(MULTICAST_PORT, 1900).
3+
-define(OPTIONS, [list, {active,true}, {ip, ?MULTICAST_GROUP},{multicast_ttl, 255}, {reuseaddr,true},{multicast_loop,true}]).
4+

rebar.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{erl_opts, [debug_info]}.
2+
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
3+
{deps, [
4+
{erlbuild, ".*", {git, "[email protected]:ulfa/erlbuild.git", "HEAD"}}
5+
]}.

src/receiver.erl

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
%% Copyright 2010 Ulf Angermann
2+
%%
3+
%% Licensed under the Apache License, Version 2.0 (the "License");
4+
%% you may not use this file except in compliance with the License.
5+
%% You may obtain a copy of the License at
6+
%%
7+
%% http://www.apache.org/licenses/LICENSE-2.0
8+
%%
9+
%% Unless required by applicable law or agreed to in writing, software
10+
%% distributed under the License is distributed on an "AS IS" BASIS,
11+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
%% See the License for the specific language governing permissions and
13+
%% limitations under the License.
14+
15+
%%% -------------------------------------------------------------------
16+
%%% Author : Ulf Angermann [email protected]
17+
%%% Description :
18+
%%%
19+
%%% Created :
20+
%%% -------------------------------------------------------------------
21+
-module(receiver).
22+
23+
-behaviour(gen_server).
24+
%% --------------------------------------------------------------------
25+
%% Include files
26+
%% --------------------------------------------------------------------
27+
%% --------------------------------------------------------------------
28+
%% External exports
29+
30+
%% gen_server callbacks
31+
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
32+
-export([start_link/0]).
33+
-export([start/0]).
34+
35+
%% ====================================================================
36+
%% External functions
37+
%% ====================================================================
38+
39+
%% --------------------------------------------------------------------
40+
%% record definitions
41+
%% --------------------------------------------------------------------
42+
-record(state, {}).
43+
%% ====================================================================
44+
%% Server functions
45+
%% ====================================================================
46+
%%--------------------------------------------------------------------
47+
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
48+
%% Description: Starts the server
49+
%%--------------------------------------------------------------------
50+
start_link() ->
51+
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
52+
53+
start() ->
54+
start_link().
55+
%% --------------------------------------------------------------------
56+
%% Function: init/1
57+
%% Description: Initiates the server
58+
%% Returns: {ok, State} |
59+
%% {ok, State, Timeout} |
60+
%% ignore |
61+
%% {stop, Reason}
62+
%% --------------------------------------------------------------------
63+
init([]) ->
64+
{ok, #state{}}.
65+
66+
%% --------------------------------------------------------------------
67+
%% Function: handle_call/3
68+
%% Description: Handling call messages
69+
%% Returns: {reply, Reply, State} |
70+
%% {reply, Reply, State, Timeout} |
71+
%% {noreply, State} |
72+
%% {noreply, State, Timeout} |
73+
%% {stop, Reason, Reply, State} | (terminate/2 is called)
74+
%% {stop, Reason, State} (terminate/2 is called)
75+
%% --------------------------------------------------------------------
76+
handle_call(Request, From, State) ->
77+
Reply = ok,
78+
{reply, Reply, State}.
79+
80+
%% --------------------------------------------------------------------
81+
%% Function: handle_cast/2
82+
%% Description: Handling cast messages
83+
%% Returns: {noreply, State} |
84+
%% {noreply, State, Timeout} |
85+
%% {stop, Reason, State} (terminate/2 is called)
86+
%% --------------------------------------------------------------------
87+
handle_cast(Msg, State) ->
88+
{noreply, State}.
89+
90+
%% --------------------------------------------------------------------
91+
%% Function: handle_info/2
92+
%% Description: Handling all non call/cast messages
93+
%% Returns: {noreply, State} |
94+
%% {noreply, State, Timeout} |
95+
%% {stop, Reason, State} (terminate/2 is called)
96+
%% --------------------------------------------------------------------
97+
handle_info(Info, State) ->
98+
{noreply, State}.
99+
100+
%% --------------------------------------------------------------------
101+
%% Function: terminate/2
102+
%% Description: Shutdown the server
103+
%% Returns: any (ignored by gen_server)
104+
%% --------------------------------------------------------------------
105+
terminate(Reason, State) ->
106+
ok.
107+
108+
%% --------------------------------------------------------------------
109+
%% Func: code_change/3
110+
%% Purpose: Convert process state when code is changed
111+
%% Returns: {ok, NewState}
112+
%% --------------------------------------------------------------------
113+
code_change(OldVsn, State, Extra) ->
114+
{ok, State}.
115+
116+
%% --------------------------------------------------------------------
117+
%%% Internal functions
118+
%% --------------------------------------------------------------------
119+
%% --------------------------------------------------------------------
120+
%%% Test functions
121+
%% --------------------------------------------------------------------
122+
%% --------------------------------------------------------------------
123+
%%% Test functions
124+
%% --------------------------------------------------------------------
125+
-include_lib("eunit/include/eunit.hrl").
126+
-ifdef(TEST).
127+
-endif.

src/searcher.app.src

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{application, searcher,
2+
[
3+
{description, ""},
4+
{vsn, "1"},
5+
{registered, []},
6+
{applications, [
7+
kernel,
8+
stdlib
9+
]},
10+
{mod, { searcher_app, []}},
11+
{env, []}
12+
]}.

src/searcher.erl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
%% Copyright 2010 Ulf Angermann
2+
%%
3+
%% Licensed under the Apache License, Version 2.0 (the "License");
4+
%% you may not use this file except in compliance with the License.
5+
%% You may obtain a copy of the License at
6+
%%
7+
%% http://www.apache.org/licenses/LICENSE-2.0
8+
%%
9+
%% Unless required by applicable law or agreed to in writing, software
10+
%% distributed under the License is distributed on an "AS IS" BASIS,
11+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
%% See the License for the specific language governing permissions and
13+
%% limitations under the License.
14+
15+
%%% -------------------------------------------------------------------
16+
%%% Author : Ulf Angermann [email protected]
17+
%%% Description :
18+
%%%
19+
%%% Created : 16.02.2012
20+
%%% -------------------------------------------------------------------
21+
-module(searcher).
22+
23+
%% Application callbacks
24+
-export([start/0, stop/0]).
25+
26+
start() ->
27+
application:start(?MODULE).
28+
29+
stop() ->
30+
application:stop(?MODULE).

src/searcher_app.erl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-module(searcher_app).
2+
3+
-behaviour(application).
4+
5+
%% Application callbacks
6+
-export([start/2, stop/1]).
7+
8+
%% ===================================================================
9+
%% Application callbacks
10+
%% ===================================================================
11+
12+
start(_StartType, _StartArgs) ->
13+
searcher_sup:start_link().
14+
15+
stop(_State) ->
16+
ok.

src/searcher_sup.erl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
-module(searcher_sup).
3+
4+
-behaviour(supervisor).
5+
6+
%% API
7+
-export([start_link/0]).
8+
9+
%% Supervisor callbacks
10+
-export([init/1]).
11+
12+
%% Helper macro for declaring children of supervisor
13+
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
14+
15+
%% ===================================================================
16+
%% API functions
17+
%% ===================================================================
18+
19+
start_link() ->
20+
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
21+
22+
%% ===================================================================
23+
%% Supervisor callbacks
24+
%% ===================================================================
25+
26+
init([]) ->
27+
{ok, { {one_for_one, 5, 10}, [?CHILD(sender, worker), ?CHILD(receiver, worker)]} }.
28+

0 commit comments

Comments
 (0)