public sendHeaderError ( string &error_message ) : void | ||
error_message | string | |
리턴 | void |
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); }
public bool handleHeader(Header header) { if (!header.Values.Contains("topic")) { string msg = "Header from subscriber did not have the required element: topic"; EDB.WriteLine(msg); connection.sendHeaderError(ref msg); return(false); } string name = (string)header.Values["topic"]; string client_callerid = (string)header.Values["callerid"]; Publication pt = TopicManager.Instance.lookupPublication(name); if (pt == null) { string msg = "received a connection for a nonexistent topic [" + name + "] from [" + connection.transport + "] [" + client_callerid + "]"; EDB.WriteLine(msg); connection.sendHeaderError(ref msg); return(false); } string error_message = ""; if (!pt.validateHeader(header, ref error_message)) { connection.sendHeaderError(ref error_message); EDB.WriteLine(error_message); return(false); } destination_caller_id = client_callerid; connection_id = ConnectionManager.Instance.GetNewConnectionID(); name = pt.Name; parent = pt; lock (parent) { max_queue = parent.MaxQueue; } IDictionary m = new Hashtable(); m["type"] = pt.DataType; m["md5sum"] = pt.Md5sum; m["message_definition"] = pt.MessageDefinition; m["callerid"] = this_node.Name; m["latching"] = pt.Latch; connection.writeHeader(m, onHeaderWritten); pt.addSubscriberLink(this); #if DEBUG EDB.WriteLine("Finalize transport subscriber link for " + name); #endif return(true); }