internal bool advertiseService <MReq, MRes>(AdvertiseServiceOptions <MReq, MRes> ops) where MReq : IRosMessage, new() where MRes : IRosMessage, new() { lock (shutting_down_mutex) { if (shutting_down) { return(false); } } lock (service_publications_mutex) { if (isServiceAdvertised(ops.service)) { EDB.WriteLine("Tried to advertise a service that is already advertised in this node [{0}]", ops.service); return(false); } if (ops.helper == null) { ops.helper = new ServiceCallbackHelper <MReq, MRes>(ops.srv_func); } ServicePublication <MReq, MRes> pub = new ServicePublication <MReq, MRes>(ops.service, ops.md5sum, ops.datatype, ops.req_datatype, ops.res_datatype, ops.helper, ops.callback_queue, ops.tracked_object); service_publications.Add(pub); } XmlRpcValue args = new XmlRpcValue(), result = new XmlRpcValue(), payload = new XmlRpcValue(); args.Set(0, this_node.Name); args.Set(1, ops.service); args.Set(2, string.Format("rosrpc://{0}:{1}", network.host, connection_manager.TCPPort)); args.Set(3, xmlrpc_manager.uri); master.execute("registerService", args, ref result, ref payload, true); return(true); }
public ServiceCallback(ServicePublication <MReq, MRes> sp, ServiceCallbackHelper <MReq, MRes> _helper, byte[] buf, int num_bytes, IServiceClientLink link, bool has_tracked_object, object tracked_object) { isp = sp; if (isp != null && _helper != null) { isp.helper = _helper; } buffer = buf; _numBytes = num_bytes; this.link = link; _hasTrackedObject = has_tracked_object; _trackedObject = tracked_object; }