internal bool unadvertiseService(string service) { lock (shutting_down_mutex) { if (shutting_down) { return(false); } } IServicePublication pub = null; lock (service_publications_mutex) { foreach (IServicePublication sp in service_publications) { if (sp.name == service && !sp.isDropped) { pub = sp; service_publications.Remove(sp); break; } } } if (pub != null) { unregisterService(pub.name); pub.drop(); return(true); } return(false); }
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); }