write_any() public method

public write_any ( OtpErlangObject o ) : void
o OtpErlangObject
return void
        /**
         * Convert this tuple to the equivalent Erlang external representation.
         *
         * @param buf
         *                an output stream to which the encoded tuple should be
         *                written.
         */
        public override void encode(OtpOutputStream buf)
        {
            int arity = elems.Length;

            buf.write_tuple_head(arity);

            for (int i = 0; i < arity; i++)
            {
                buf.write_any(elems[i]);
            }
        }
        /*
         * Send an auth error to peer because he sent a bad cookie. The auth error
         * uses his cookie (not revealing ours). This is just like send_reg
         * otherwise
         */
        private void cookieError(OtpLocalNode local, OtpErlangAtom cookie)
        {
            try
            {
                OtpOutputStream header = new OtpOutputStream(headerLen);

                // preamble: 4 byte length + "passthrough" tag + version
                header.write4BE(0); // reserve space for length
                header.write1(passThrough);
                header.write1(version);

                header.write_tuple_head(4);
                header.write_long(regSendTag);
                header.write_any(local.createPid()); // disposable pid
                header.write_atom(cookie.atomValue()); // important: his cookie,
                // not mine...
                header.write_atom("auth");

                // version for payload
                header.write1(version);

                // the payload

                // the no_auth message (copied from Erlang) Don't change this
                // (Erlang will crash)
                // {$gen_cast, {print, "~n** Unauthorized cookie ~w **~n",
                // [foo@aule]}}
                OtpErlangObject[] msg = new OtpErlangObject[2];
                OtpErlangObject[] msgbody = new OtpErlangObject[3];

                msgbody[0] = new OtpErlangAtom("print");
                msgbody[1] = new OtpErlangString("~n** Bad cookie sent to " + local + " **~n");

                // Erlang will crash and burn if there is no third argument here...
                msgbody[2] = new OtpErlangList(); // empty list

                msg[0] = new OtpErlangAtom("$gen_cast");
                msg[1] = new OtpErlangTuple(msgbody);

                OtpOutputStream payload = new OtpOutputStream(new OtpErlangTuple(msg));

                // fix up length in preamble
                header.poke4BE(0, header.size() + payload.size() - 4);

                try
                {
                    do_send(header, payload);
                }
                catch (IOException)
                {
                } // ignore
            }
            finally
            {
                close();
            }
            throw new OtpAuthException("Remote cookie not authorized: " + cookie.atomValue());
        }
        private void sendExit(int tag, OtpErlangPid from, OtpErlangPid dest, OtpErlangObject reason)
        {
            if (!connected)
            {
                throw new IOException("Not connected");
            }
            OtpOutputStream header = new OtpOutputStream(headerLen);

            // preamble: 4 byte length + "passthrough" tag
            header.write4BE(0); // reserve space for length
            header.write1(passThrough);
            header.write1(version);

            // header
            header.write_tuple_head(4);
            header.write_long(tag);
            header.write_any(from);
            header.write_any(dest);
            header.write_any(reason);

            // fix up length in preamble
            header.poke4BE(0, header.size() - 4);

            do_send(header);
        }
        /**
         * Send a pre-encoded message to a process on a remote node.
         *
         * @param dest
         *            the Erlang PID of the remote process.
         * @param msg
         *            the encoded message to send.
         *
         * @exception java.io.IOException
         *                if the connection is not active or a communication error
         *                occurs.
         */
        protected void sendBuf(OtpErlangPid from, OtpErlangPid dest, OtpOutputStream payload)
        {
            if (!connected)
            {
                throw new IOException("Not connected");
            }
            OtpOutputStream header = new OtpOutputStream(headerLen);

            // preamble: 4 byte length + "passthrough" tag + version
            header.write4BE(0); // reserve space for length
            header.write1(passThrough);
            header.write1(version);

            // header info
            header.write_tuple_head(3);
            header.write_long(sendTag);
            if (sendCookie)
            {
                header.write_atom(self.Cookie);
            }
            else
            {
                header.write_atom("");
            }
            header.write_any(dest);

            // version for payload
            header.write1(version);

            // fix up length in preamble
            header.poke4BE(0, header.size() + payload.size() - 4);

            do_send(header, payload);
        }