Exemple #1
0
        private async Task StartReadHeader(Connection connection)
        {
            try
            {
                var headerFields = await connection.ReadHeader(cancel);

                if (headerFields.ContainsKey("topic"))
                {
                    TransportSubscriberLink subscriberLink = new TransportSubscriberLink();
                    subscriberLink.Initialize(connection, new Header(headerFields));
                }
                else if (headerFields.ContainsKey("service"))
                {
                    IServiceClientLink serviceClientLink = new IServiceClientLink();
                    serviceClientLink.Initialize(connection, new Header(headerFields));
                }
                else
                {
                    throw new RosException("Received a connection for a type other than topic or service.");
                }
            }
            catch (Exception e)
            {
                logger.LogWarning(e, e.Message);
                connection.Dispose();
            }
        }
Exemple #2
0
        public bool OnConnectionHeaderReceived(Connection conn, Header header)
        {
            bool ret = false;

            if (header.Values.ContainsKey("topic"))
            {
                TransportSubscriberLink sub_link = new TransportSubscriberLink();
                ret  = sub_link.Initialize(conn);
                ret &= sub_link.HandleHeader(header);
            }
            else if (header.Values.ContainsKey("service"))
            {
                IServiceClientLink iscl = new IServiceClientLink();
                ret  = iscl.initialize(conn);
                ret &= iscl.handleHeader(header);
            }
            else
            {
                ROS.Warn()($"[{ThisNode.Name}] Got a connection for a type other than topic or service from [{conn.RemoteString}].");
                return(false);
            }
            //ROS.Debug()( $"[{ThisNode.Name}] CONNECTED [{val}]. WIN." );
            return(ret);
        }