summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-11 04:42:02 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-11 04:42:02 +0100
commita13aa77e4f298945a43eaf3a67b4e575a2c79373 (patch)
tree83482fb5121bbaea0bab6491cc47d2d4f64e48d3
parentad394e819ad166e8cbdf8bc899905c7bab8df244 (diff)
Event stub
-rw-r--r--src/pbx_acse.erl42
-rw-r--r--src/pbx_conn.erl2
2 files changed, 44 insertions, 0 deletions
diff --git a/src/pbx_acse.erl b/src/pbx_acse.erl
index 3b17614..9a3cf47 100644
--- a/src/pbx_acse.erl
+++ b/src/pbx_acse.erl
@@ -1,8 +1,12 @@
-module(pbx_acse).
+-behaviour(gen_event).
-include("ACSE-1.hrl").
-include("CSTA-application-context-information-csta3.hrl").
+-export([start_link/0, add_handler/2]).
+-export([init/1, handle_event/2, handle_call/2, handle_info/2,
+ terminate/2, code_change/3]).
-export([encode/1, decode/1]).
encode(userinformation) ->
@@ -37,3 +41,41 @@ decode({asn1_ExtAlt, Data}) ->
decode(<<Data/binary>>) ->
{ok, Pdu} = 'ACSE-1':decode('ACSE-apdu', Data),
decode(Pdu).
+
+%%%
+
+start_link() ->
+ gen_event:start_link({local, ?MODULE}).
+
+add_handler(Handler, Args) ->
+ gen_event:add_handler(?MODULE, Handler, Args).
+
+init(_Args) ->
+ {ok, []}.
+
+handle_event({aare, #'AARE-apdu'{result = Result}}, _State) ->
+ io:format("AARE ~p~n", [Result]),
+ {ok, Result}; % accepted or rejected
+handle_event({rlre, _}, _State) ->
+ io:format("RLRE~n"),
+ {ok, released};
+handle_event({abrt, _}, _State) ->
+ io:format("ABRT~n"),
+ {ok, aborted};
+handle_event(_Event, State) ->
+ io:format("ELSE~n"),
+ {ok, State}.
+
+handle_call(association, State) ->
+ {ok, State, State};
+handle_call(_Request, State) ->
+ {ok, ok, State}.
+
+handle_info(_Info, State) ->
+ {ok, State}.
+
+terminate(_Reason, _State) ->
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
diff --git a/src/pbx_conn.erl b/src/pbx_conn.erl
index 8326b84..b79aa80 100644
--- a/src/pbx_conn.erl
+++ b/src/pbx_conn.erl
@@ -10,6 +10,7 @@
-include("config.hrl").
start_link() ->
+ %pbx_acse:start_link(),
gen_server:start_link({local, ?SERVER}, ?MODULE, [?HOST, ?PORT], []).
init(Args) ->
@@ -30,6 +31,7 @@ handle_info({tcp, _, Data}, Socket) ->
pbx_acse:decode(Data),
Pdu = pbx_pdu:decode(Data),
io:format("PDU ~p~n", [Pdu]),
+ %gen_event:notify(pbx_acse, Pdu),
{noreply, Socket};
handle_info({tcp_closed, _}, Socket) ->