Esempio n. 1
0
        /*
         * OtpCookedConnection delivers messages here return true if message was
         * delivered successfully, or false otherwise.
         */
        public bool deliver(OtpMsg m)
        {
            OtpMbox mbox = null;

            try
            {
                int t = m.type();

                if (t == OtpMsg.regSendTag)
                {
                    String name = m.getRecipientName();
                    /* special case for netKernel requests */
                    if (name.Equals("net_kernel"))
                    {
                        return netKernel(m);
                    }
                    else
                    {
                        mbox = mboxes.get(name);
                    }
                }
                else
                {
                    mbox = mboxes.get(m.getRecipientPid());
                }

                if (mbox == null)
                {
                    return false;
                }
                mbox.deliver(m);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Esempio n. 2
0
        /*
         * this method simulates net_kernel only for the purpose of replying to
         * pings.
         */
        private bool netKernel(OtpMsg m)
        {
            OtpMbox mbox = null;
            try
            {
                OtpErlangTuple t = (OtpErlangTuple)m.getMsg();
                OtpErlangTuple req = (OtpErlangTuple)t.elementAt(1); // actual
                // request

                OtpErlangPid pid = (OtpErlangPid)req.elementAt(0); // originating
                // pid

                OtpErlangObject[] pong = new OtpErlangObject[2];
                pong[0] = req.elementAt(1); // his #Ref
                pong[1] = new OtpErlangAtom("yes");

                mbox = createMbox(true);
                mbox.send(pid, new OtpErlangTuple(pong));
                return true;
            }
            catch (Exception)
            {
            }
            finally
            {
                closeMbox(mbox);
            }
            return false;
        }
 /**
  * Deliver messages to the recipient.
  */
 public abstract void deliver(OtpMsg msg);
Esempio n. 4
0
 public override void deliver(OtpMsg msg)
 {
     queue.put(msg);
 }
        /*
         * pass the message to the node for final delivery. Note that the connection
         * itself needs to know about links (in case of connection failure), so we
         * snoop for link/unlink too here.
         */
        public override void deliver(OtpMsg msg)
        {
            bool delivered = self.deliver(msg);

            switch (msg.type())
            {
                case OtpMsg.linkTag:
                    if (delivered)
                    {
                        links.addLink(msg.getRecipientPid(), msg.getSenderPid());
                    }
                    else
                    {
                        try
                        {
                            // no such pid - send exit to sender
                            base.sendExit(msg.getRecipientPid(), msg.getSenderPid(), new OtpErlangAtom("noproc"));
                        }
                        catch (IOException)
                        {
                        }
                    }
                    break;

                case OtpMsg.unlinkTag:
                case OtpMsg.exitTag:
                    links.removeLink(msg.getRecipientPid(), msg.getSenderPid());
                    break;

                case OtpMsg.exit2Tag:
                    break;
            }

            return;
        }
Esempio n. 6
0
 public override void deliver(OtpMsg m)
 {
     base.deliver(m);
     sched.notify(this);
 }
Esempio n. 7
0
        /*
         * called by OtpNode to deliver message to this mailbox.
         *
         * About exit and exit2: both cause exception to be raised upon receive().
         * However exit (not 2) causes any link to be removed as well, while exit2
         * leaves any links intact.
         */
        public virtual void deliver(OtpMsg m)
        {
            switch (m.type())
            {
                case OtpMsg.linkTag:
                    links.addLink(self, m.getSenderPid());
                    break;

                case OtpMsg.unlinkTag:
                    links.removeLink(self, m.getSenderPid());
                    break;

                case OtpMsg.exitTag:
                    links.removeLink(self, m.getSenderPid());
                    queue.put(m);
                    break;

                case OtpMsg.exit2Tag:
                default:
                    queue.put(m);
                    break;
            }
        }