From 09703ef5c6181570388e99a74ddf3d871869801b Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 11 Nov 2015 16:26:29 +0100 Subject: WIP --- src/pbx_conn.erl | 2 +- src/pbx_rose.erl | 24 ++++++++++++++---------- src/pbx_status.erl | 19 ++++--------------- 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(<>) -> %%% 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}. -- cgit v1.2.3