예제 #1
0
파일: backend.py 프로젝트: sgreg/smartplug
    def __init__(self, listenUrl):
        WebSocketServerFactory.__init__(self, listenUrl)

        # List of connected websocket clients
        self.clients = []
        # List of received smartplug data
        self.smartplugs = {}
예제 #2
0
    def __init__(self):
        WebSocketServerFactory.__init__(self)
        logging.debug("Using WebSocket module " + str(self.server))

        self.openHandshakeTimeout   = 20
        self.closeHandshakeTimeout  =  5

        self.clients    = []    # for broadcast
    def __init__(self, config, *args, **kwargs):
        WebSocketServerFactory.__init__(self, *args, **kwargs)
        for module_name, module_data in config["modules"].items():
            module_import_name = re.sub('(?!^)([A-Z]+)', r'_\1', module_data["type"]).lower()
            self.modules[module_name] = module_data

            module_module = importlib.import_module("modules."+module_import_name)
            module_object = getattr(module_module, module_data["type"])
            self.modules[module_name]["module_object"] = module_object(**module_data)
예제 #4
0
    def __init__(self):
        WebSocketServerFactory.__init__(self)
        logging.debug("Using WebSocket module " + str(self.server))
        from mdbapi.server import cfg

        self.openHandshakeTimeout = cfg.websocket.opentimeout
        self.closeHandshakeTimeout = cfg.websocket.closetimeout

        self.clients = []  # for broadcast
예제 #5
0
 def __init__(self, url, config="config.json", *args, **kwargs):
     WebSocketServerFactory.__init__(self, url, *args, **kwargs)
     self.clients = []
     with open(config) as configfile:
         self.config.update(json.load(configfile))
     self.config['switchModule'] = importlib.import_module(self.config['switchModule'])
     for name in self.config["switches"]:
         switch_config = self.config['switches'][name]
         switch_class = switch_config['class']
         initial_data = switch_config
         switch = getattr(self.config["switchModule"], switch_class)(initial_data=initial_data, name=name, factory=self)
         self.config['switches'][name]['class'] = switch
예제 #6
0
    def __init__(self, config_file):

        # init before get called
        self.contexts = {}
        self.context_subscriptions = {}

        Application.__init__(self, config_file)
        WebSocketServerFactory.__init__(self)

        #greenlet.greenlet.__init__(self)

        # start the separate tasker process
        IN.tasker.start_the_process()
예제 #7
0
	def __init__(self, socketAddress, socketPort):
		WebSocketServerFactory.__init__(self, u"ws://%s:%d" % (socketAddress, socketPort), False)
		self.protocol = ProtocolHandler
		# Lets keep track of the address and port for use later.
		self.socketAddress = socketAddress
		self.socketPort = socketPort
		# Some stuff for the protocol...
		self.activeConnections = []
		self.generatedSnakes = []
		self.maxSnakeId = 100
		self.timestamp = 0
		self.snakeTravelSpeed = 10
		self.generatedFood = []
예제 #8
0
    def __init__(self):
        WebSocketServerFactory.__init__(self)

        self.state = {
            "current_song": None,
            "queue": [],
            "playing": True,
            "magic_mode": True,
            "duration_limit": None,
            "history": []
        }

        self.clients = []
예제 #9
0
	def __init__(self, config_file):
		
		# init before get called
		self.contexts = {}
		self.context_subscriptions = {}
		
		Application.__init__(self, config_file)
		WebSocketServerFactory.__init__(self)
		
		#greenlet.greenlet.__init__(self)
		
		# start the separate tasker process
		IN.tasker.start_the_process()
예제 #10
0
    def __init__(self):
        WebSocketServerFactory.__init__(self)
        logging.debug("Using WebSocket module " + str(self.server))
        from mdbapi.server import cfg

        self.openHandshakeTimeout = cfg.websocket.opentimeout
        self.closeHandshakeTimeout = cfg.websocket.closetimeout
        #logging.debug("openHandshakeTimeout = " + str(self.openHandshakeTimeout))
        #logging.debug("closeHandshakeTimeout= " + str(self.closeHandshakeTimeout))
        #logging.debug("autoPingTimeout      = " + str(self.autoPingTimeout))
        #logging.debug("autoPingInterval     = " + str(self.autoPingInterval))
        #logging.debug("server               = " + str(self.server))
        #logging.debug("isSecure             = " + str(self.isSecure))

        self.clients = []  # for broadcast
예제 #11
0
    def __init__(self, url, debug=False, ident=None):
        if ident is not None:
            server = ident
        else:
            server = "AutobahnPython-Asyncio/%s" % autobahn.version
        WebSocketServerFactory.__init__(self, url, debug=debug, debugCodePaths=debug, server=server)
        self.setProtocolOptions(failByDrop=False)  # spec conformance
        self.setProtocolOptions(failByDrop=True)  # needed for streaming mode
        # self.setProtocolOptions(utf8validateIncoming = False)

        # enable permessage-deflate
        ##
        def accept(offers):
            for offer in offers:
                if isinstance(offer, PerMessageDeflateOffer):
                    return PerMessageDeflateOfferAccept(offer)

        self.setProtocolOptions(perMessageCompressionAccept=accept)
    def __init__(self, url):
        testee_ident = autobahn.asyncio.__ident__
        self.log.info("Testee identification: {testee_ident}", testee_ident=testee_ident)
        WebSocketServerFactory.__init__(self, url, server=testee_ident)

        self.setProtocolOptions(failByDrop=False)  # spec conformance
        # self.setProtocolOptions(utf8validateIncoming = False)

        if USE_STREAMING_TESTEE:
            self.setProtocolOptions(failByDrop=True)  # needed for streaming mode
        else:
            # enable permessage-deflate WebSocket protocol extension
            def accept(offers):
                for offer in offers:
                    if isinstance(offer, PerMessageDeflateOffer):
                        return PerMessageDeflateOfferAccept(offer)

            self.setProtocolOptions(perMessageCompressionAccept=accept)
예제 #13
0
    def __init__(self, url, debug=False, ident=None):
        if ident is not None:
            server = ident
        else:
            server = "AutobahnPython-Asyncio/%s" % autobahn.version
        WebSocketServerFactory.__init__(self, url, debug=debug, debugCodePaths=debug, server=server)
        self.setProtocolOptions(failByDrop=False)  # spec conformance
        self.setProtocolOptions(failByDrop=True)  # needed for streaming mode
        # self.setProtocolOptions(utf8validateIncoming = False)

        # enable permessage-deflate
        ##
        def accept(offers):
            for offer in offers:
                if isinstance(offer, PerMessageDeflateOffer):
                    return PerMessageDeflateOfferAccept(offer)

        self.setProtocolOptions(perMessageCompressionAccept=accept)
예제 #14
0
    def __init__(self, url):
        testee_ident = autobahn.asyncio.__ident__
        self.log.info("Testee identification: {testee_ident}",
                      testee_ident=testee_ident)
        WebSocketServerFactory.__init__(self, url, server=testee_ident)

        self.setProtocolOptions(failByDrop=False)  # spec conformance
        # self.setProtocolOptions(utf8validateIncoming = False)

        if USE_STREAMING_TESTEE:
            self.setProtocolOptions(
                failByDrop=True)  # needed for streaming mode
        else:
            # enable permessage-deflate WebSocket protocol extension
            def accept(offers):
                for offer in offers:
                    if isinstance(offer, PerMessageDeflateOffer):
                        return PerMessageDeflateOfferAccept(offer)

            self.setProtocolOptions(perMessageCompressionAccept=accept)
예제 #15
0
    def __init__(self, url, zmq_endpoint, server_type, debug=False, debugCodePaths=False):
        WebSocketServerFactory.__init__(self, url, debug=debug, debugCodePaths=debugCodePaths)
        self.tickcount = 0

        self.server_type = server_type

        self.cleanClientsTimeout = 1
        self.clientMaxTimeout = 30
        self.statsTimeout = 1

        self.clients = {}

        self.context = zmq.Context()
        self.recv_context = self.context.socket(zmq.PULL)
        self.recv_context.bind(zmq_endpoint)

        self.cycleTracker = [0]

        self.timeouts = [0]
        self.packetLoss = [0]

        self.messagesCount = 0
예제 #16
0
 def __init__(self, *args):
     WebSocketServerFactory.__init__(self, *args)
     self.clients = []
예제 #17
0
파일: pysib.py 프로젝트: desmovalvo/pysib
 def __init__(self, url, host, port, graph):
     print "INIT FACTORY"
     WebSocketServerFactory.__init__(self, url, host, port, graph)
     self.sib_host = host
     self.sib_port = port
     self.graph = graph
예제 #18
0
 def __init__(self, url):
     WebSocketServerFactory.__init__(self, url)
     self.clients = []
     self.tickcount = 0
     self.tick()
예제 #19
0
 def __init__(self, daq, **kwargs):
     WebSocketServerFactory.__init__(self, **kwargs)
     self.daq = daq
     self.clients = list()
예제 #20
0
 def __init__(self, *args, **kwargs):
     WebSocketServerFactory.__init__(self, *args, **kwargs)
     self.clients = []
     self.subscriptions = {}
예제 #21
0
 def __init__(self, url, image_dir, session_age, restored_messages):
     WebSocketServerFactory.__init__(self, url)
     self._cookies = {}
     self.image_dir = image_dir
     self.session_max_age = session_age
     self.restored_messages = restored_messages
예제 #22
0
 def __init__(self, url, callbacks, debug=False, debugCodePaths=False):
     WebSocketServerFactory.__init__(self, url, debug=debug, debugCodePaths=debugCodePaths)
     self.__callbacks = callbacks
     self.__clients = []
예제 #23
0
 def __init__(self):
     WebSocketServerFactory.__init__(self, "ws://127.0.0.1:9000")
     self.clients = set()
     self.virtual_device = ServerVirtualDevice()
     self.device = self.virtual_device.get_device()
예제 #24
0
파일: factory.py 프로젝트: ides15/yote
 def __init__(self, url):
     WebSocketServerFactory.__init__(self, url)
     self.clients = []
예제 #25
0
 def __init__(self, url, debug = False, debugCodePaths = False):
     WebSocketServerFactory.__init__(self, url, debug, debugCodePaths)
     self.clients = []
예제 #26
0
파일: choo.py 프로젝트: raphaelm/choo
 def __init__(self, url, debug=False, debugCodePaths=False):
     WebSocketServerFactory.__init__(self,
                                     url,
                                     debug=debug,
                                     debugCodePaths=debugCodePaths)
예제 #27
0
    def __init__(self, verbose=False):
        WebSocketServerFactory.__init__(self)

        self.verbose = verbose
        self.clients = []
예제 #28
0
 def __init__(self, url):
     WebSocketServerFactory.__init__(self, url)
 def __init__(self, url):
     WebSocketServerFactory.__init__(self, url)
     self.clients = []
     self.tickcount = 0
     self.tick()