public static void Main(string[] args) { OtpNode self = new OtpNode(new NodeDetails() { Node = "vaplug", Cookie = "edsrv_cookie", Flags = OtpInputStream.StreamFlags.DecodeIntListsAsStrings }); OtpMbox mbox = self.CreateMbox("test"); OtpErlangTuple tuple = new OtpErlangTuple( mbox.Self, new OtpErlangTuple( new OtpErlangAtom("echo"), new OtpErlangString(OtpErlangString.FromCodePoints(new int[] { 127744, 32, 69, 108, 32, 78, 105, 241, 111 })) // 🌀 El Niño ) ); //send message to registered process hello_server on node one @grannysmith //> { hello_server, 'one@grannysmith'} ! test. mbox.Send("edsrv@GAMING", "player_srv", tuple); Logger.Debug("<- REPLY " + mbox.Receive()); var reply = self.RPC("edsrv@GAMING", 1000, "edlib", "log_dir"); Logger.Debug("<- LOG " + reply); }
public static void Main(string[] args) { OtpNode a = new OtpNode("a"); OtpNode b = new OtpNode("b"); OtpActorMbox echo = (OtpActorMbox)b.createMbox("echo", false); b.react(new OtpEchoActor(echo)); OtpMbox echoback = a.createMbox("echoback", true); OtpErlangObject[] v = { echoback.Self, new OtpErlangString("Hello, World!") }; echoback.send(echo.Self, new OtpErlangTuple(v)); log.Debug("<- ECHO (back) " + echoback.receive()); b.close(); a.close(); }
public override IEnumerator <Continuation> GetEnumerator() { OtpMbox mbox = base.Mbox; OtpMsg msg = null; while (true) { yield return(delegate(OtpMsg m) { msg = m; }); log.Debug("-> ECHO " + msg.getMsg()); OtpErlangTuple t = (OtpErlangTuple)msg.getMsg(); OtpErlangPid sender = (OtpErlangPid)t.elementAt(0); OtpErlangObject[] v = { mbox.Self, t.elementAt(1) }; mbox.send(sender, new OtpErlangTuple(v)); } }
public static void Main(string[] args) { OtpNode b = new OtpNode("b"); var echo = b.CreateMbox("echo"); echo.Received += (e) => { OtpErlangTuple t = (OtpErlangTuple)e.Msg.Payload; OtpErlangPid sender = (OtpErlangPid)t.ElementAt(0); Logger.Debug($"-> ECHO {t.ElementAt(1)} from {sender}"); t[0] = e.Mbox.Self; e.Mbox.Send(sender, t); }; OtpNode a = new OtpNode("a"); OtpMbox echoback = a.CreateMbox("echoback"); echoback.Send(echo.Self, new OtpErlangTuple(echoback.Self, new OtpErlangString("Hello, World!"))); Logger.Debug($"<- ECHO (back) {echoback.ReceiveMsg()}"); a.Close(); b.Close(); }
static public void Main(String[] args) { System.Console.Out.WriteLine("Otp test..."); string cookie = OtpNode.defaultCookie; AbstractConnection.traceLevel = OtpTrace.Type.sendThreshold; if (args.Length < 1) { System.Console.Out.WriteLine( "Usage: {0} nodename [cookie] [-notrace]\n" + " nodename - is the name of the remote Erlang node\n" + " cookie - is the optional cookie string to use\n" + " -notrace - disable debug trace\n", Environment.GetCommandLineArgs()[0]); return; } else if (args.Length > 1) { cookie = args[1].ToString(); } for (int i = 0; i < args.Length; i++) { if (args[i].Equals("-notrace")) { AbstractConnection.traceLevel = OtpTrace.Type.defaultLevel; break; } } String host = System.Net.Dns.GetHostName(); String remote = (args[0].IndexOf('@') < 0) ? args[0] + "@" + host : args[0]; OtpNode node = new OtpNode(false, Environment.UserName + "123@" + host, cookie, true); System.Console.Out.WriteLine("This node is called {0} and is using cookie='{1}'.", node.node(), node.cookie()); bool ok = node.ping(remote, 1000); if (!ok) { Console.WriteLine("Can't connect to node " + remote); return; } // If using short names, get the short name of the peer. remote = node.connection(remote).peer.node(); if (remote != null) { System.Console.Out.WriteLine(" successfully pinged node " + remote + "\n"); } else { System.Console.Out.WriteLine(" could not ping node " + remote + "\n"); } OtpMbox mbox = null; try { mbox = node.createMbox(); { Otp.Erlang.Object reply = mbox.rpcCall( remote, "lists", "reverse", new Otp.Erlang.List("Abcdef!")); System.Console.Out.WriteLine("<= [REPLY1]:" + (reply == null ? "null" : reply.ToString())); } { Otp.Erlang.Object reply = mbox.rpcCall( remote, "global", "register_name", new Otp.Erlang.List(new Otp.Erlang.Atom("me"), mbox.self())); System.Console.Out.WriteLine("<= [REPLY2]:" + (reply == null ? "null" : reply.ToString())); } { Otp.Erlang.Object reply = mbox.rpcCall(remote, "global", "register_name", new Otp.Erlang.List(new Otp.Erlang.Atom("me"), mbox.self()), 5000); System.Console.Out.WriteLine("<= [REPLY3]:" + (reply == null ? "null" : reply.ToString())); } { Otp.Erlang.Object reply = mbox.rpcCall( remote, "io", "format", new Otp.Erlang.List( "Test: ~w -> ~w\n", new Otp.Erlang.List(mbox.self(), new Otp.Erlang.Atom("ok")) )); System.Console.Out.WriteLine("<= [REPLY4]:" + (reply == null ? "null" : reply.ToString())); } while (true) { Otp.Erlang.Object msg = mbox.receive(); if (msg is Otp.Erlang.Tuple) { Otp.Erlang.Tuple m = msg as Otp.Erlang.Tuple; if (m.arity() == 2 && m.elementAt(0) is Otp.Erlang.Pid) { mbox.send(m.elementAt(0) as Otp.Erlang.Pid, m.elementAt(1)); } } System.Console.Out.WriteLine("IN msg: " + msg.ToString() + "\n"); } } catch (System.Exception e) { System.Console.Out.WriteLine("Error: " + e.ToString()); } finally { node.closeMbox(mbox); } node.close(); }