summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-11 16:26:29 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-11 16:26:29 +0100
commit09703ef5c6181570388e99a74ddf3d871869801b (patch)
tree95b5cd23bc3a7cda1568b0a6a350a834dbb6c26b
parent8346e23acabd2a94dc50fd84316221d6790f7f90 (diff)
WIP
-rw-r--r--src/pbx_conn.erl2
-rw-r--r--src/pbx_rose.erl24
-rw-r--r--src/pbx_status.erl19
3 files changed, 19 insertions, 26 deletions
diff --git a/src/pbx_conn.erl b/src/pbx_conn.erl
index 631fde6..d02b0c3 100644
--- a/src/pbx_conn.erl
+++ b/src/pbx_conn.erl
@@ -30,7 +30,7 @@ handle_cast({error, Reason}, Socket) ->
{stop, Reason, Socket}.
handle_info({tcp, _, Data}, Socket) ->
- pbx_acse:decode(Data),
+ %pbx_acse:decode(Data),
Pdu = pbx_pdu:decode(Data),
io:format("PDU ~p~n", [Pdu]),
gen_event:notify(pbx_pdu, Pdu),
diff --git a/src/pbx_rose.erl b/src/pbx_rose.erl
index ab73064..76cb89e 100644
--- a/src/pbx_rose.erl
+++ b/src/pbx_rose.erl
@@ -81,24 +81,25 @@ decode(<<Data/binary>>) ->
%%%
init(_Args) ->
- io:format("Init rose~n"),
- {ok, []}.
+ {ok, {present, 0}}.
-handle_event({invoke, Invoke = #'Invoke'{}}, State) ->
+handle_event({invoke, Invoke = #'Invoke'{}}, _State) ->
io:format("Invoke ~p~n", [Invoke]),
- {ok, State};
-handle_event({returnResult, ReturnResult = #'ReturnResult'{}}, State) ->
+ {ok, Invoke#'Invoke'.invokeId};
+handle_event({returnResult, ReturnResult = #'ReturnResult'{}}, _State) ->
io:format("ReturnResult ~p~n", [ReturnResult]),
- {ok, State};
-handle_event({returnError, ReturnError = #'ReturnError'{}}, State) ->
+ {ok, ReturnResult#'ReturnResult'.invokeId};
+handle_event({returnError, ReturnError = #'ReturnError'{}}, _State) ->
io:format("ReturnError ~p~n", [ReturnError]),
- {ok, State};
-handle_event({reject, Reject = #'Reject'{}}, State) ->
+ {ok, ReturnError#'ReturnError'.invokeId};
+handle_event({reject, Reject = #'Reject'{}}, _State) ->
io:format("Reject ~p~n", [Reject]),
- {ok, State};
+ {ok, Reject#'Reject'.invokeId};
handle_event(_Event, State) ->
{ok, State}.
+handle_call(nextInvoke, State) ->
+ {ok, next(State), next(State)};
handle_call(_Request, State) ->
{ok, ok, State}.
@@ -110,3 +111,6 @@ terminate(_Reason, _State) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+
+next({present, N}) ->
+ {present, N+1}.
diff --git a/src/pbx_status.erl b/src/pbx_status.erl
index 5e2ca82..548e16a 100644
--- a/src/pbx_status.erl
+++ b/src/pbx_status.erl
@@ -21,27 +21,16 @@ value({ok, #'SystemStatusArg'{systemStatus = Status}}) ->
value(Data) ->
value(decode(Data)).
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%
-start_link() ->
- gen_event:start_link({local, ?MODULE}).
-
-add_handler(Handler, Args) ->
- gen_event:add_handler(?MODULE, Handler, Args).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
--record(state, {}).
-
-init([]) ->
- {ok, #state{}}.
+init(_Args) ->
+ {ok, []}.
handle_event(_Event, State) ->
{ok, State}.
handle_call(_Request, State) ->
- Reply = ok,
- {ok, Reply, State}.
+ {ok, ok, State}.
handle_info(_Info, State) ->
{ok, State}.