/*
         * Pass a 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)
                {
                    lock (lockObj)
                        links.AddLink(msg.ToPid, msg.FromPid);
                    break;
                }

                // no such pid - send exit to sender
                try { SendExit(msg.ToPid, msg.FromPid, new OtpErlangAtom("noproc")); }
                catch (IOException) { }
                break;

            case OtpMsg.unlinkTag:
            case OtpMsg.exitTag:
                lock (lockObj)
                    links.RemoveLink(msg.ToPid, msg.FromPid);
                break;

            case OtpMsg.exit2Tag:
                break;
            }
        }
Esempio n. 2
0
        /**
         * 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 OtpErlangPid pid}.
         */
        public void Unlink(OtpErlangPid to)
        {
            links.RemoveLink(Self, to);

            try
            {
                string node = to.Node;
                if (node.Equals(home.Node))
                {
                    home.Deliver(new OtpMsg(OtpMsg.unlinkTag, Self, to));
                }
                else
                {
                    OtpCookedConnection conn = home.GetConnection(node);
                    if (conn != null)
                    {
                        conn.Unlink(Self, to);
                    }
                }
            }
            catch (Exception) { }
        }