/*
         * 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.Tag.linkTag:
                if (delivered)
                {
                    links.addLink(msg.getRecipientPid(), msg.getSenderPid());
                }
                else
                {
                    try
                    {
                        // no such pid - send exit to sender
                        base.sendExit(msg.getRecipientPid(), msg.getSenderPid(), "noproc");
                    }
                    catch (System.IO.IOException)
                    {
                    }
                }
                break;

            case OtpMsg.Tag.monitorPTag:
                if (delivered)
                {
                    monitors[msg.getSenderPid()] = msg.getMsg();
                }
                else
                {
                    try
                    {
                        base.sendExit(msg.getRecipientPid(), msg.getSenderPid(), "noproc");
                    }
                    catch (System.IO.IOException)
                    {
                    }
                }
                break;

            case OtpMsg.Tag.demonitorPTag:
            case OtpMsg.Tag.monitorPexitTag:
                monitors.Remove(msg.getSenderPid());
                break;

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

            case OtpMsg.Tag.exit2Tag:
                break;
            }
            return;
        }
Exemple #2
0
        /*
         * <p> Remove a link to a remote mailbox or Erlang process. This
         * method removes a link created with {@link #link link()}.
         * Links are idempotent; calling this method once will remove all
         * links between this mailbox and the remote {@link Pid
         * pid}. </p>
         *
         * @param to the {@link Pid pid} representing the object to
         * unlink from.
         *
         **/
        public virtual void  unlink(Erlang.Pid to)
        {
            links.removeLink(_self, to);

            try
            {
                System.String node = to.node();
                if (node.Equals(home.node()))
                {
                    home.deliver(new OtpMsg(OtpMsg.Tag.unlinkTag, _self, to));
                }
                else
                {
                    OtpCookedConnection conn = home.connection(node);
                    if (conn != null)
                    {
                        conn.unlink(_self, to);
                    }
                }
            }
            catch (System.Exception)
            {
            }
        }