Ros_CSharp.TcpTransport.parseHeader C# (CSharp) Method

parseHeader() public method

public parseHeader ( Header header ) : void
header Header
return void
        public void parseHeader(Header header)
        {
            if (_topic == null)
            {
                if (header.Values.Contains("topic"))
                    _topic = header.Values["topic"].ToString();
            }
            string nodelay = "";
            if (header.Values.Contains("tcp_nodelay"))
                nodelay = (string) header.Values["tcp_nodelay"];
            if (nodelay == "1")
            {
                setNoDelay(true);
            }
        }

Usage Example

Example #1
0
        private bool onHeaderRead(Connection conn, byte[] data, int size, bool success)
        {
            if (conn != this)
            {
                throw new Exception("THAT EVENT IS NOT FOR MEEE!");
            }
            if (!success)
            {
                return(false);
            }
            string error_msg = "";

            if (!header.Parse(data, (int)size, ref error_msg))
            {
                drop(DropReason.HeaderError);
                return(false);
            }
            else
            {
                string error_val = "";
                if (header.Values.Contains("error"))
                {
                    error_val = (string)header.Values["error"];
                    EDB.WriteLine("Received error message in header for connection to [{0}]: [{1}]",
                                  "TCPROS connection to [" + transport.cached_remote_host + "]", error_val);
                    drop(DropReason.HeaderError);
                    return(false);
                }
                else
                {
                    if (header_func == null)
                    {
                        throw new Exception("AMG YOUR HEADERFUNC SUCKS");
                    }
                    transport.parseHeader(header);
                    header_func(conn, header);
                }
            }
            return(true);
        }