I'm using the UPnP Object Method IUPnPDeviceFinder
::[CreateAsyncFind][1]
and the third parameter is a callback function.
I've tried to create my own COM Object but the method don't call back my function. Here's my code:
class Callback():
_public_methods_ = ['DeviceAdded','DeviceRemoved', 'SearchComplete']
_reg_progid_ = "UPnP.PythonCallback"
_reg_clsid_ = pythoncom.CreateGuid()
def DeviceAdded (device, UDN, calltype):
print (device, ": ", calltype, " UDN: ", UDN)
return
win32com.server.register.UseCommandLine(Callback)
callserver = Dispatch("UPnP.PythonCallback")
deviceType = "urn:schemas-upnp-org:device:MediaServer:1"
devices = finder.CreateAsyncFind(deviceType,0, callserver)
finder.StartAsyncFind(devices)
Actually, I just need something like this:
def DeviceAdded (device, UDN, calltype):
print (device, ": ", calltype, " UDN: ", UDN)
return
deviceType = "urn:schemas-upnp-org:device:MediaServer:1"
devices = finder.CreateAsyncFind(deviceType,0, DeviceAdded)
finder.StartAsyncFind(devices)
Microsoft made a example on VBScript. That's exactly what I want to do on Python (http://msdn.microsoft.com/en-us/library/windows/desktop/aa381078(v=VS.85).aspx) How can I pass a function as a parameter on a COM Object?