Added more protocol
This commit is contained in:
parent
34b4c1d072
commit
43a51430bc
5 changed files with 3802 additions and 4406 deletions
|
@ -10,10 +10,11 @@ port = gets
|
|||
|
||||
s = TCPSocket.open(hostname, port.chop)
|
||||
|
||||
s.print(" __boot")
|
||||
s.print("__hello")
|
||||
|
||||
while true
|
||||
line = s.gets # Read lines from the socket
|
||||
puts "Got Echo: " + line.chop # And print with platform line terminator
|
||||
puts ">> " + line.chop # And print with platform line terminator
|
||||
s.print(gets.chop)
|
||||
end
|
||||
s.close # Close the socket when done
|
||||
|
|
8154
erl_crash.dump
8154
erl_crash.dump
File diff suppressed because it is too large
Load diff
|
@ -6,20 +6,21 @@
|
|||
|
||||
parse(Data) ->
|
||||
Message = string:tokens(Data, " "),
|
||||
io:format(Message),
|
||||
case Message of
|
||||
[RefID, "__error", Message ] ->
|
||||
[RefID, "__error", Size, Message ] ->
|
||||
{ok, you_said_error};
|
||||
[_, "__boot" ] ->
|
||||
[_, "__boot", _ ] ->
|
||||
{ok, you_said_boot};
|
||||
[RefID, "__stop"] ->
|
||||
[RefID, "__stop", _] ->
|
||||
{ok, you_said_stop};
|
||||
[RefID, "__start"] ->
|
||||
[RefID, "__start", _] ->
|
||||
{ok, you_said_start};
|
||||
[_, "__hello" , _ ] ->
|
||||
{ok, you_said_hello};
|
||||
[RefID, "__define", JavaScript ] ->
|
||||
["__hello", _] ->
|
||||
{hello};
|
||||
[RefID, "__define",_, JavaScript ] ->
|
||||
{ok, you_said_define};
|
||||
[RefID, Command, Parameter ] ->
|
||||
[RefID, Command, _, Parameter ] ->
|
||||
{cmd, Command, Parameter};
|
||||
Other ->
|
||||
{out_of_bounds, Other}
|
||||
|
|
|
@ -73,9 +73,7 @@ handle_cast(stop, State) ->
|
|||
|
||||
handle_info({tcp, Socket, RawData}, State) ->
|
||||
do_JSDefine(Socket, RawData),
|
||||
%Parsed = ggs_protocol:parse(RawData),
|
||||
RequestCount = State#state.request_count,
|
||||
%gen_tcp:send(Socket, io_lib:fwrite("~p~n", [Parsed])),
|
||||
{noreply, State#state{request_count = RequestCount + 1}};
|
||||
|
||||
handle_info(timeout, #state{lsock = LSock} = State) ->
|
||||
|
@ -101,10 +99,20 @@ do_JSDefine(Socket, Data) ->
|
|||
Ret = js_runner:call(JSVM, "userCommand",
|
||||
[list_to_binary(Command),
|
||||
list_to_binary(Parameter)]),
|
||||
gen_tcp:send(Socket, io_lib:fwrite("JS says: ~p~n", [Ret]));
|
||||
send(Socket, "JS says: ", Ret);
|
||||
{hello} ->
|
||||
io:format("Got hello!"),
|
||||
send(Socket, make_ref(), "__ok_hello");
|
||||
Other ->
|
||||
ok
|
||||
io:format("Got '~p'", [Other]),
|
||||
send(Socket, "__error")
|
||||
end.
|
||||
|
||||
do_JSCall(Socket, Function, Parameters) ->
|
||||
ok.
|
||||
ok.
|
||||
|
||||
send(Socket, String) ->
|
||||
gen_tcp:send(Socket, io_lib:fwrite("~p~n", [String])).
|
||||
|
||||
send(Socket, String1, String2) ->
|
||||
gen_tcp:send(Socket, io_lib:fwrite("~p ~p~n", [String1, String2])).
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
-module(v8test).
|
||||
-export([run/0]).
|
||||
-include_lib("erlv8/include/erlv8.hrl").
|
||||
|
||||
run() ->
|
||||
application:start(erlv8),
|
||||
{ok, VM} = erlv8_vm:start(),
|
||||
Global = erlv8_vm:global(VM),
|
||||
Global:set_value("callback", erlv8_object:new([{"exec", fun (#erlv8_fun_invocation{}, []) -> myCallback() end}])),
|
||||
erlv8_vm:run(VM,"callback.exec();").
|
||||
|
||||
myCallback() ->
|
||||
io:format("Hello from myCallback!~n", []),
|
||||
ok.
|
Reference in a new issue