Example #1
0
        public bool handleHeader(Header header)
        {
            if (!header.Values.Contains("md5sum") || !header.Values.Contains("service") || !header.Values.Contains("callerid"))
            {
                string bbq = "Bogus tcpros header. did not have required elements: md5sum, service, callerid";
                ROS.Error(bbq);
                connection.sendHeaderError(ref bbq);
                return(false);
            }
            string md5sum          = (string)header.Values["md5sum"];
            string service         = (string)header.Values["service"];
            string client_callerid = (string)header.Values["client_callerid"];

            if (header.Values.Contains("persistent") && ((string)header.Values["persistent"] == "1" || (string)header.Values["persistent"] == "true"))
            {
                persistent = true;
            }

            ROS.Debug("Service client [{0}] wants service [{1}] with md5sum [{2}]", client_callerid, service, md5sum);
            IServicePublication isp = ServiceManager.Instance.lookupServicePublication(service);

            if (isp == null)
            {
                string bbq = string.Format("received a tcpros connection for a nonexistent service [{0}]", service);
                ROS.Error(bbq);
                connection.sendHeaderError(ref bbq);
                return(false);
            }

            if (isp.md5sum != md5sum && md5sum != "*" && isp.md5sum != "*")
            {
                string bbq = "client wants service " + service + " to have md5sum " + md5sum + " but it has " + isp.md5sum + ". Dropping connection";
                ROS.Error(bbq);
                connection.sendHeaderError(ref bbq);
                return(false);
            }

            if (isp.isDropped)
            {
                string bbq = "received a tcpros connection for a nonexistent service [" + service + "]";
                ROS.Error(bbq);
                connection.sendHeaderError(ref bbq);
                return(false);
            }

            parent = isp;
            IDictionary m = new Hashtable();

            m["request_type"]  = isp.req_datatype;
            m["response_type"] = isp.res_datatype;
            m["type"]          = isp.datatype;
            m["md5sum"]        = isp.md5sum;
            m["callerid"]      = this_node.Name;

            connection.writeHeader(m, onHeaderWritten);

            isp.addServiceClientLink(this);
            return(true);
        }
Example #2
0
        public virtual CallResult call()
        {
            ROS.Debug("CALLED PEERCONNDISCONNCALLBACK");
            SingleSubscriberPublisher pub = new SingleSubscriberPublisher(sub_link);

            callback(pub);
            return(CallResult.Success);
        }
Example #3
0
        private void onConnectionDropped(Connection connection, Connection.DropReason dr)
        {
            if (connection != this.connection)
            {
                throw new Exception("WRONG CONNECTION ZOMG!");
            }

            ROS.Debug("Service client from [{0}] for [{1}] dropped", connection.RemoteString, name);

            clearCalls();

            ServiceManager.Instance.removeServiceServerLink(this);
        }