Browse Source

SSDP is now a proper protocol, and doesn't require things too be

setup immediately..  This does mean we have to queue up packets...

This means our caller doesn't have to know about SSDP_ADDR anymore...

Though we should still provide a function to start us up..

[git-p4: depot-paths = "//depot/": change = 1270]
main
John-Mark Gurney 16 years ago
parent
commit
21738804c0
1 changed files with 20 additions and 1 deletions
  1. +20
    -1
      SSDP.py

+ 20
- 1
SSDP.py View File

@@ -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)


Loading…
Cancel
Save