Write() public method

public Write ( IDictionary dict, byte &buffer, int &totallength ) : void
dict IDictionary
buffer byte
totallength int
return void
Exemplo n.º 1
0
        public void writeHeader(IDictionary key_vals, WriteFinishedFunc finished_func)
        {
            header_written_callback = finished_func;
            if (!transport.getRequiresHeader())
            {
                onHeaderWritten(this);
                return;
            }
            int len = 0;

            byte[] buffer = null;
            header.Write(key_vals, ref buffer, ref len);
            uint msg_len = (uint)len + 4;

            byte[] full_msg = new byte[msg_len];
            uint   j        = 0;

            byte[] blen = Header.ByteLength(len);
            for (; j < 4; j++)
            {
                full_msg[j] = blen[j];
            }
            for (uint i = 0; j < msg_len; j++)
            {
                i           = j - 4;
                full_msg[j] = buffer[i];
            }
            write(full_msg, msg_len, onHeaderWritten, true);
        }
Exemplo n.º 2
0
        public static bool exists(string service_name, bool print_failure_reason)
        {
            string mapped_name = names.resolve(service_name);

            string host = "";
            int port = 0;

            if (ServiceManager.Instance.lookUpService(mapped_name, ref host, ref port))
            {
                TcpTransport transport = new TcpTransport();

                IDictionary m = new Hashtable
                {
                    {"probe", "1"},
                    {"md5sum", "*"},
                    {"callerid", this_node.Name},
                    {"service", mapped_name}
                };

                byte[] headerbuf = null;
                int size = 0;
                Header h = new Header();
                h.Write(m, ref headerbuf, ref size);

                if (transport.connect(host, port))
                {
                    byte[] sizebuf = BitConverter.GetBytes(size);

                    transport.write(sizebuf, 0, sizebuf.Length);
                    transport.write(headerbuf, 0, size);

                    return true;
                }
                if (print_failure_reason)
                {
                    ROS.Info("waitForService: Service[{0}] could not connect to host [{1}:{2}], waiting...", mapped_name, host, port);
                }
            }
            else if (print_failure_reason)
            {
                ROS.Info("waitForService: Service[{0}] has not been advertised, waiting...", mapped_name);
            }
            return false;
        }
Exemplo n.º 3
0
        public static bool exists(string service_name, bool print_failure_reason)
        {
            string mapped_name = names.resolve(service_name);

            string host = "";
            int    port = 0;

            if (ServiceManager.Instance.lookUpService(mapped_name, ref host, ref port))
            {
                TcpTransport transport = new TcpTransport();

                IDictionary m = new Hashtable
                {
                    { "probe", "1" },
                    { "md5sum", "*" },
                    { "callerid", this_node.Name },
                    { "service", mapped_name }
                };

                byte[] headerbuf = null;
                int    size      = 0;
                Header h         = new Header();
                h.Write(m, ref headerbuf, ref size);

                if (transport.connect(host, port))
                {
                    byte[] sizebuf = BitConverter.GetBytes(size);

                    transport.write(sizebuf, 0, sizebuf.Length);
                    transport.write(headerbuf, 0, size);

                    return(true);
                }
                if (print_failure_reason)
                {
                    ROS.Info("waitForService: Service[{0}] could not connect to host [{1}:{2}], waiting...", mapped_name, host, port);
                }
            }
            else if (print_failure_reason)
            {
                ROS.Info("waitForService: Service[{0}] has not been advertised, waiting...", mapped_name);
            }
            return(false);
        }