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); }
/// <summary> /// Advertises a ServiceServer with specified OPTIONS /// </summary> /// <typeparam name="MReq">Request sub-srv type</typeparam> /// <typeparam name="MRes">Response sub-srv type</typeparam> /// <param name="ops">isn't it obvious?</param> /// <returns>The ServiceServer that will call the ServiceFunction on behalf of ServiceClients</returns> public ServiceServer advertiseService <MReq, MRes>(AdvertiseServiceOptions <MReq, MRes> ops) where MReq : IRosMessage, new() where MRes : IRosMessage, new() { ops.service = resolveName(ops.service); if (ops.callback_queue == null) { ops.callback_queue = Callback ?? ROS.GlobalCallbackQueue; } if (ServiceManager.Instance.advertiseService(ops)) { ServiceServer srv = new ServiceServer(ops.service, this); lock (collection.mutex) { collection.serviceservers.Add(srv); } return(srv); } throw new Exception("Something ain't right with this advertisement."); }