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