Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
        }