diff --git a/SSDP.py b/SSDP.py index 2dbb1b2..3b08b2c 100644 --- a/SSDP.py +++ b/SSDP.py @@ -39,6 +39,20 @@ class SSDPServer(DatagramProtocol): known = {} maxage = 7 * 24 * 60 * 60 + def __init__(self): + # XXX - no init? + #DatagramProtocol.__init__(self) + self.__notifyqueue = [] + + def startProtocol(self): + self.transport.joinGroup(SSDP_ADDR) + # so we don't get our own sends + self.transport.setLoopbackMode(0) + self.doNotify = self.realdoNotify + for i in self.__notifyqueue: + self.doNotify(i) + self.__notifyqueue = None + def doStop(self): '''Make sure we send out the byebye notifications.''' @@ -142,7 +156,12 @@ class SSDPServer(DatagramProtocol): self.transport.write(resp, (SSDP_ADDR, SSDP_PORT)) self.transport.write(resp, (SSDP_ADDR, SSDP_PORT)) - def doNotify(self, st): + def queueDoNotify(self, st): + self.__notifyqueue.append(st) + + doNotify = queueDoNotify + + def realdoNotify(self, st): """Do notification""" log.msg('Sending alive notification for %s' % st)