def send_add(self, service): broadcast = {"command": "add", "port": self.bus.port, "service": service.id, "info": service.info} broadcast = json.dumps(broadcast) net.sendto(self.sender, broadcast, ("127.255.255.255", constants.broadcast_port)) net.sendto(self.sender, broadcast, ("255.255.255.255", constants.broadcast_port))
def send_remove(self, service): broadcast = {"command": "remove", "port": self.bus.port, "service": service.id} broadcast = json.dumps(broadcast) # Send remove messages in the opposite order of discover messages net.sendto(self.sender, broadcast, ("255.255.255.255", constants.broadcast_port)) net.sendto(self.sender, broadcast, ("127.255.255.255", constants.broadcast_port))
def send_initial_requests(self): for delay in constants.query_initial_intervals: for i in range(int(delay*10.0)): # Sleep in 100ms blocks so that if the # discoverer is shut down in the middle, we'll terminate fairly # quickly time.sleep(0.1) if not self.running: return net.sendto(self.sender, json.dumps({"command": "query"}), ("127.255.255.255", constants.broadcast_port)) net.sendto(self.sender, json.dumps({"command": "query"}), ("255.255.255.255", constants.broadcast_port))