Go to the documentation of this file.00001 from rosbridge_library.capability import Capability
00002 from advertise_service import ServiceList
00003
00004 try:
00005 import ujson as json
00006 except ImportError:
00007 try:
00008 import simplejson as json
00009 except ImportError:
00010 import json
00011
00012
00013 class StopService(Capability):
00014 opcode_unadvertise_service = "stop_service"
00015
00016 service_list = ServiceList().list
00017
00018 def __init__(self, protocol):
00019 self.protocol = protocol
00020 Capability.__init__(self, protocol)
00021 protocol.register_operation(self.opcode_unadvertise_service, self.unadvertise_service)
00022
00023 def unadvertise_service(self, message):
00024 service_name = message["service_name"]
00025 client_id = self.protocol.client_id
00026
00027
00028 if service_name in self.service_list.keys():
00029 if client_id == self.service_list[service_name].client_id:
00030 self.service_list[service_name].stop_ROS_service()
00031 else:
00032 self.protocol.log("warning", "tried to remove service: " + service_name + " ['owned' by client: " + str(self.service_list[service_name].client_id) + "]")
00033 else:
00034 self.protocol.log("warning", "tried to remove service: " + service_name + " [service was not registered]")
00035
00036 def finish(self):
00037 self.protocol.unregister_operation("unadvertise_server")
00038
00039
00040
00041
00042
00043
00044
00045