# Path: resources/lib/model/mdnscomputer.py
# class MdnsComputer:
# 
#     def __init__(self, service_type=None, name=None, address=None, port=None, server=None):
#         self.service_type = service_type
#         self.name = name
#         self.address = address
#         self.port = port
#         self.server = server
# 
#     @classmethod
#     def from_service_info(cls, service_info):
#         mdnscomputer = cls(
#             service_info.type,
#             service_info.name,
#             '.'.join(str(ord(i)) for i in service_info.address),
#             service_info.port,
#             service_info.server
#         )
# 
#         return mdnscomputer


import time
from zeroconf import ServiceBrowser, Zeroconf, ServiceStateChange
from resources.lib.model.mdnscomputer import MdnsComputer



class DiscoveryAgent(object):
    service_type = '_nvstream._tcp.local.'

    def __init__(self):
        self.available_hosts = {}
        self.zeroconf = None
        self.browser = None

    def service_state_change(self, zeroconf, service_type, name, state_change):
        if state_change is ServiceStateChange.Added:
            info = zeroconf.get_service_info(service_type, name)

# Path: resources/lib/model/mdnscomputer.py
# class MdnsComputer:
# 
#     def __init__(self, service_type=None, name=None, address=None, port=None, server=None):
#         self.service_type = service_type
#         self.name = name
#         self.address = address
#         self.port = port
#         self.server = server
# 
#     @classmethod
#     def from_service_info(cls, service_info):
#         mdnscomputer = cls(
#             service_info.type,
#             service_info.name,
#             '.'.join(str(ord(i)) for i in service_info.address),
#             service_info.port,
#             service_info.server
#         )
# 
#         return mdnscomputer


# Path: resources/lib/nvhttp/mdns/discoveryagent.py
import time
from zeroconf import ServiceBrowser, Zeroconf, ServiceStateChange
from resources.lib.model.mdnscomputer import MdnsComputer




class DiscoveryAgent(object):
    service_type = '_nvstream._tcp.local.'

    def __init__(self):
        self.available_hosts = {}
        self.zeroconf = None
        self.browser = None

    def service_state_change(self, zeroconf, service_type, name, state_change):
        if state_change is ServiceStateChange.Added:
            info = zeroconf.get_service_info(service_type, name)

            self.available_hosts[name] = MdnsComputer.from_service_info(info)