Commits

arkdro committed 566025d

add info api

  • Participants
  • Parent commits 0b6cb8a

Comments (0)

Files changed (1)

File erlang/src/c_server.erl

 -behaviour(gen_server).
 
 -export([
+         info/1,
          get/0,
          multiply/1,
          ping/0
 get() ->
     gen_server:call(?SERVER, get).
 
+info(Term) ->
+    gen_server:call(?SERVER, {info, Term}).
+
 %-------------------------------------------------------------------
 multiply(List) ->
     gen_server:call(?SERVER, {mult, List}).
 handle_call(ping, From, #state{status=running, port=Port} = State) ->
     port_command(Port, term_to_binary(ping)),
     {noreply, State#state{from=From}};
+handle_call({info, Term}, From, #state{status=running, port=Port} = State) ->
+    Cmd = term_to_binary({info, Term}),
+    port_command(Port, Cmd),
+    {noreply, State#state{from=From}};
 handle_call(get, From, #state{status=running, port=Port} = State) ->
     Cmd = term_to_binary({get, none}),
     port_command(Port, Cmd),
     {noreply, State#state{from=From}};
 handle_call({mult, Term}, From, #state{status=running, port=Port} = State) ->
-    Cmd = term_to_binary({ms, Term}),
+    Cmd = term_to_binary({mult_list, Term}),
     port_command(Port, Cmd),
     {noreply, State#state{from=From}};
 handle_call(stop, _From, St) ->