Пример #1
0
##my_sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

from threading import Thread
def pump_cp_UDP():
    global bRunning
    bRunning = True
    while(bRunning):
            cp._ssdp_server.udp_listener._receive_datagram(None, None)

def print_UDP(arg1, arg2):
    print my_sock.recvfrom(1500)
    
thReactor = Thread(target=reactor.main, name="Reactor", args=())

cp.start()
cp.start_search(5)

#reactor.add_fd(my_sock, print_UDP, EVENT_TYPE_READ)
thReactor.start()

g_Households = {}
g_sids = {}

def getHHIDs():
    global cp, g_Households
    for (udn, device) in cp.get_devices().iteritems():
        if ("RINCON" in udn):
            dp_svc = device.services[cp.DP_namespace]
            hhid = dp_svc.GetHouseholdID().values()[0]
            if hhid not in g_Households:
                # Store this zp as my associated zp