Commits

arkdro committed 871aaee

add round-trip mode

  • Participants
  • Parent commits f87c24d

Comments (0)

Files changed (1)

       Trace.dbg "handle_payload" "other\n%s\n%!" (Eterm.to_string other);
       Eterm.ET_atom "error"
 
-let create_main_process node name =
+let create_main_process node name round_trip =
     let mbox = Enode.create_mbox node in
     let _ = Enode.register_mbox node mbox name in
     let recvCB = fun msg -> match msg with
+    | Eterm.ET_tuple [|toPid; ref; x;|] when round_trip = true ->
+      let filler = Eterm.ET_tuple [|Eterm.ET_int (1l);
+                                    Eterm.ET_int (2l);
+                                    Eterm.ET_int (3l);|] in
+      Enode.send
+        node
+        toPid
+        (Eterm.ET_tuple [| ref; filler; |])
     | Eterm.ET_tuple [|toPid; ref; (Eterm.ET_atom "stop");|] ->
       Trace.dbg "n1 worker" "stop message received\n%!";
       Enode.stop node;
     try
         let name = ref "ocaml" in
         let cookie = ref "" in
+        let round_trip = ref false in
         Arg.parse
             [
+                ("-round_trip", Arg.Bool ((:=) round_trip), "round trip  mode");
                 ("-cookie", Arg.String ((:=) cookie), "erlang node cookie");
                 ("-name", Arg.String ((:=) name), "erlang node name");
                 ("-debug", Arg.Unit (fun () -> Trace.set_level Trace.lvl_debug), "print debug messages");
         let n = Enode.create !name ~cookie:!cookie in
         let _ = Thread.sigmask Unix.SIG_BLOCK [Sys.sigint] in
         let _ = Enode.start n in
-        let _ = create_main_process n "byn" in
+        let _ = create_main_process n "byn" !round_trip in
         let _ = Thread.wait_signal [Sys.sigint] in
         Enode.stop n
     with