summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-11 19:38:46 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-11 19:38:46 +0100
commit7bf02af36d8aabcd108547bb8ef700d1a039a2ad (patch)
treea6b1beefc1184f385db0a49a25616132609c4b44
parent144eee643d1e2e0d5cfebf761ea565ae46e1f98b (diff)
kiss
-rw-r--r--src/pbx_rose.erl21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/pbx_rose.erl b/src/pbx_rose.erl
index fb0a8cd..de81aa5 100644
--- a/src/pbx_rose.erl
+++ b/src/pbx_rose.erl
@@ -18,13 +18,9 @@ init(_Args) ->
handle_event({invoke, Invoke = ?INVOKE(Id, ?STATUS, Data)}, _State) ->
Status = pbx_status:decode(Data),
- io:format("Status: ~p~n", [Status]),
- case pbx_status:value(Status) of
- normal ->
- reply(Invoke, pbx_status:encode());
- _ ->
- ok
- end,
+ Value = pbx_status:value(Status),
+ io:format("Status: ~p~n", [Value]),
+ reply(Invoke, Value),
{ok, Id};
handle_event({invoke, ?INVOKE(Id, ?EVENT, Data)}, _State) ->
{ok, Event} = pbx_event:decode(Data),
@@ -89,14 +85,17 @@ code_change(_OldVsn, State, _Extra) ->
next({present, N}) ->
{present, N+1}.
-reply(Invoke = #'Invoke'{}, Data) ->
- pbx_conn:send(return(Invoke, Data)).
+reply(Invoke = #'Invoke'{}, normal) ->
+ Data = pbx_status:encode(),
+ Reply = return(Invoke, Data),
+ pbx_conn:send(Reply);
+reply(_Invoke, _) ->
+ ok.
return(#'Invoke'{invokeId = Id, opcode = Op}, {ok, Data}) ->
Result = #'ReturnResult_result'{opcode = Op, result = Data},
ReturnResult = #'ReturnResult'{invokeId = Id, result = Result},
- 'Remote-Operations-Generic-ROS-PDUs':encode('ROS', {returnResult,
- ReturnResult}).
+ 'Remote-Operations-Generic-ROS-PDUs':encode('ROS', {returnResult, ReturnResult}).
invoke(Op, {ok, Data}) ->
Id = pbx_pdu:call(?MODULE, nextInvoke),