コード例 #1
0
 // exit (etc) has from, to, reason
 internal OtpMsg(int tag, OtpErlangPid from, OtpErlangPid to, IOtpErlangObject reason)
 {
     Type    = tag;
     FromPid = from;
     ToPid   = to;
     payload = reason;
 }
コード例 #2
0
 // special case when reason is an atom (i.e. most of the time)
 internal OtpMsg(int tag, OtpErlangPid from, OtpErlangPid to, string reason)
 {
     Type    = tag;
     FromPid = from;
     ToPid   = to;
     payload = new OtpErlangAtom(reason);
 }
コード例 #3
0
 // send_reg has sender pid and receiver name
 internal OtpMsg(OtpErlangPid from, string toName, IOtpErlangObject payload)
 {
     Type         = regSendTag;
     FromPid      = from;
     ToName       = toName;
     this.payload = payload;
 }
コード例 #4
0
 // send_reg has sender pid and receiver name
 internal OtpMsg(OtpErlangPid from, string toName, OtpInputStream paybuf)
 {
     Type    = regSendTag;
     FromPid = from;
     ToName  = toName;
     Stream  = paybuf;
 }
コード例 #5
0
 // other message types (link, unlink)
 internal OtpMsg(int tag, OtpErlangPid from, OtpErlangPid to)
 {
     // convert TT-tags to equiv non-TT versions
     Type    = (tag > 10 ? tag - 10 : tag);
     FromPid = from;
     ToPid   = to;
 }
コード例 #6
0
            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));
                }
            }
コード例 #7
0
ファイル: echo.cs プロジェクト: reganheath/Erlang.NET
        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();
        }
コード例 #8
0
 // send has receiver pid but no sender information
 internal OtpMsg(OtpErlangPid to, IOtpErlangObject payload)
 {
     Type         = sendTag;
     ToPid        = to;
     this.payload = payload;
 }
コード例 #9
0
 // send has receiver pid but no sender information
 internal OtpMsg(OtpErlangPid to, OtpInputStream paybuf)
 {
     Type   = sendTag;
     ToPid  = to;
     Stream = paybuf;
 }