Now you can list all vms with __get_vms (just for testing)
This commit is contained in:
parent
af75d731b4
commit
3d8b413a8f
3 changed files with 10 additions and 4 deletions
|
@ -10,7 +10,7 @@ port = gets
|
|||
|
||||
s = TCPSocket.open(hostname, port.chop)
|
||||
|
||||
s.print("__hello")
|
||||
s.print("__hello 0")
|
||||
|
||||
while true
|
||||
line = s.gets # Read lines from the socket
|
||||
|
|
|
@ -8,6 +8,8 @@ parse(Data) ->
|
|||
Message = string:tokens(Data, " "),
|
||||
io:format(Message),
|
||||
case Message of
|
||||
["__get_vms"] ->
|
||||
{vms};
|
||||
[RefID, "__error", Size, Message ] ->
|
||||
{ok, you_said_error};
|
||||
[_, "__boot", _ ] ->
|
||||
|
@ -23,10 +25,12 @@ parse(Data) ->
|
|||
[RefID, "__echo", Length, Msg ] ->
|
||||
{Ref, _} = string:to_integer(RefID),
|
||||
{echo, Ref, Length, Msg};
|
||||
[RefID, Command, _, Parameter ] ->
|
||||
{cmd, Command, Parameter};
|
||||
%% Debugging tools, not for production use
|
||||
["__crash"] ->
|
||||
{crash, 0};
|
||||
[RefID, Command, _, Parameter ] ->
|
||||
{cmd, Command, Parameter};
|
||||
%% End debugging tools
|
||||
Other ->
|
||||
{out_of_bounds, Other}
|
||||
end.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
%% @end
|
||||
%%-----------------------------------------------------
|
||||
start_link(Port) ->
|
||||
process_flag(trap_exit, true),
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [Port], []).
|
||||
|
||||
start_link() ->
|
||||
|
@ -114,9 +115,10 @@ do_JSCall(Socket, Data, State) ->
|
|||
[];
|
||||
{crash, Zero} ->
|
||||
10/Zero;
|
||||
{vms} ->
|
||||
send(Socket, "RefID", State);
|
||||
% Set the new state to []
|
||||
Other ->
|
||||
io:format("Got '~p'", [Other]),
|
||||
send(Socket, "RefID", "__error"),
|
||||
[]
|
||||
end,
|
||||
|
|
Reference in a new issue