def send_NOTIFY(self, nt, uuid=None, nts="ssdp:alive"): if self.ssdp.device.bootID is None: self.ssdp.device.bootID = int(time.time()) location = self.ssdp.device.getLocation(get_default_v4_address()) if uuid is None: uuid = self.ssdp.device.uuid usn, nt = build_notification_type(uuid, nt) log.msg("send_NOTIFY %s:%s" % (nts, usn)) headers = { # max-age is notifySequenceInterval + 10 minutes "CACHE-CONTROL": "max-age = %d" % (self.notifySequenceInterval + (10 * 60)), "LOCATION": location, "SERVER": self.ssdp.device.server, "NT": nt, "NTS": nts, "USN": usn, "BOOTID.UPNP.ORG": self.ssdp.device.bootID, "CONFIGID.UPNP.ORG": self.ssdp.device.configID, } self.send("NOTIFY", headers, (SSDP_ADDR_V4, SSDP_PORT))
def send_NOTIFY(self, nt, uuid=None, nts='ssdp:alive'): if self.ssdp.device.bootID is None: self.ssdp.device.bootID = int(time.time()) location = self.ssdp.device.getLocation(get_default_v4_address()) if uuid is None: uuid = self.ssdp.device.uuid usn, nt = build_notification_type(uuid, nt) log.msg("send_NOTIFY %s:%s" % (nts, usn)) headers = { # max-age is notifySequenceInterval + 10 minutes 'CACHE-CONTROL': 'max-age = %d' % (self.notifySequenceInterval + (10 * 60)), 'LOCATION': location, 'SERVER': self.ssdp.device.server, 'NT': nt, 'NTS': nts, 'USN': usn, 'BOOTID.UPNP.ORG': self.ssdp.device.bootID, 'CONFIGID.UPNP.ORG': self.ssdp.device.configID } self.send('NOTIFY', headers, (SSDP_ADDR_V4, SSDP_PORT))
self.transport.write(msg, (address, port)) except socket.error, e: log.err("socket.error: %s" % e) def respond_MSEARCH(self, st, (address, port)): log.msg("respond_MSEARCH to %s:%s, headers=%s" % (address, port, st)) if self.ssdp.device.bootID is None: self.ssdp.device.bootID = int(time.time()) if address == "127.0.0.1": location = self.ssdp.device.getLocation("127.0.0.1") else: location = self.ssdp.device.getLocation(get_default_v4_address()) usn, st = build_notification_type(self.ssdp.device.uuid, st) headers = { "CACHE-CONTROL": "max-age = %d" % self.responseExpire, "EXT": "", "LOCATION": location, "SERVER": self.ssdp.device.server, "ST": st, "USN": usn, "OPT": '"http://schemas.upnp.org/upnp/1/0/"; ns=01', "01-NLS": self.ssdp.device.bootID, "BOOTID.UPNP.ORG": self.ssdp.device.bootID, "CONFIGID.UPNP.ORG": self.ssdp.device.configID, } self.respond(headers, (address, port))
self.transport.write(msg, (address, port)) except socket.error, e: log.err("socket.error: %s" % e) def respond_MSEARCH(self, st, (address, port)): log.msg("respond_MSEARCH to %s:%s, headers=%s" % (address, port, st)) if self.ssdp.device.bootID is None: self.ssdp.device.bootID = int(time.time()) if address == '127.0.0.1': location = self.ssdp.device.getLocation('127.0.0.1') else: location = self.ssdp.device.getLocation(get_default_v4_address()) usn, st = build_notification_type(self.ssdp.device.uuid, st) headers = { 'CACHE-CONTROL': 'max-age = %d' % self.responseExpire, 'EXT': '', 'LOCATION': location, 'SERVER': self.ssdp.device.server, 'ST': st, 'USN': usn, 'OPT': '"http://schemas.upnp.org/upnp/1/0/"; ns=01', '01-NLS': self.ssdp.device.bootID, 'BOOTID.UPNP.ORG': self.ssdp.device.bootID, 'CONFIGID.UPNP.ORG': self.ssdp.device.configID, } self.respond(headers, (address, port))