Ros_CSharp.Header.Write C# (CSharp) 메소드

Write() 공개 메소드

public Write ( IDictionary dict, byte &buffer, int &totallength ) : void
dict IDictionary
buffer byte
totallength int
리턴 void
        public void Write(IDictionary dict, ref byte[] buffer, ref int totallength)
        {
            Values = new Hashtable(dict);
            buffer = new byte[0];
            totallength = 0;
            foreach (object k in dict.Keys)
            {
                int linelength = 0;
                byte[] key = Encoding.ASCII.GetBytes((string) k);
                byte[] val = Encoding.ASCII.GetBytes(dict[k].ToString());
                totallength += val.Length + key.Length + 1 + 4;
                linelength = val.Length + key.Length + 1;
                buffer = concat(buffer, ByteLength(linelength));
                buffer = concat(buffer, key);
                buffer = concat(buffer, Encoding.ASCII.GetBytes("="));
                buffer = concat(buffer, val);
            }
            if (totallength != buffer.Length)
                throw new Exception("HEADER AIN'T WRITE GOOD! SHOULD'VE STAYED IN SCHOOL!");
        }

Usage Example

예제 #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);
        }
All Usage Examples Of Ros_CSharp.Header::Write