Пример #1
0
    def __init__(self, url, debug=False, ident=None):
        WebSocketClientFactory.__init__(self,
                                        url,
                                        useragent=ident,
                                        debug=debug,
                                        debugCodePaths=debug)
        self.setProtocolOptions(failByDrop=False)  # spec conformance

        ## enable permessage-XXX compression extensions
        ##
        offers = [PerMessageDeflateOffer()]
        #offers = [PerMessageSnappyOffer(), PerMessageBzip2Offer(), PerMessageDeflateOffer()]
        self.setProtocolOptions(perMessageCompressionOffers=offers)

        def accept(response):
            if isinstance(response, PerMessageDeflateResponse):
                return PerMessageDeflateResponseAccept(response)

            elif isinstance(response, PerMessageBzip2Response):
                return PerMessageBzip2ResponseAccept(response)

            elif isinstance(response, PerMessageSnappyResponse):
                return PerMessageSnappyResponseAccept(response)

        self.setProtocolOptions(perMessageCompressionAccept=accept)

        self.endCaseId = None
        self.currentCaseId = 0

        self.updateReports = True
        if ident is not None:
            self.agent = ident
        else:
            self.agent = "AutobahnPython/%s" % autobahn.version
        self.resource = "/getCaseCount"
Пример #2
0
    def __init__(self,
                 queue,
                 summary,
                 dirOutput,
                 contentType,
                 model,
                 url=None,
                 headers=None,
                 debug=None):

        WebSocketClientFactory.__init__(self, url=url, headers=headers)
        self.queue = queue
        self.summary = summary
        self.dirOutput = dirOutput
        self.contentType = contentType
        self.model = model
        self.queueProto = Queue.Queue()

        self.openHandshakeTimeout = 10
        self.closeHandshakeTimeout = 10

        # start the thread that takes care of ending the reactor so the script can finish automatically (without ctrl+c)
        endingThread = threading.Thread(target=self.endReactor, args=())
        endingThread.daemon = True
        endingThread.start()
Пример #3
0
   def __init__(self, url, debug = False, ident = None):
      WebSocketClientFactory.__init__(self, url, useragent = ident, debug = debug, debugCodePaths = debug)
      self.setProtocolOptions(failByDrop = False) # spec conformance

      ## enable permessage-XXX compression extensions
      ##
      offers = [PerMessageDeflateOffer()]
      #offers = [PerMessageSnappyOffer(), PerMessageBzip2Offer(), PerMessageDeflateOffer()]
      self.setProtocolOptions(perMessageCompressionOffers = offers)

      def accept(response):
         if isinstance(response, PerMessageDeflateResponse):
            return PerMessageDeflateResponseAccept(response)

         elif isinstance(response, PerMessageBzip2Response):
            return PerMessageBzip2ResponseAccept(response)

         elif isinstance(response, PerMessageSnappyResponse):
            return PerMessageSnappyResponseAccept(response)

      self.setProtocolOptions(perMessageCompressionAccept = accept)


      self.endCaseId = None
      self.currentCaseId = 0

      self.updateReports = True
      if ident is not None:
         self.agent = ident
      else:
         self.agent = "AutobahnPython/%s" % autobahn.version
      self.resource = "/getCaseCount"
Пример #4
0
        def __init__(self,
                     queue,
                     dir_output,
                     content_type,
                     model,
                     options,
                     url=None,
                     headers=None,
                     debug=None):

            WebSocketClientFactory.__init__(self, url=url, headers=headers)
            self.queue = queue
            self.dir_output = dir_output
            self.content_type = content_type
            self.model = model
            self.options = options
            self.queueProto = Queue.Queue()
            self.openHandshakeTimeout = 10
            self.closeHandshakeTimeout = 10

            # start the thread that takes care of ending the reactor so
            # script finishes, reactor shutsdown and the main loop is exited
            endingThread = threading.Thread(target=self.endReactor, args=())
            endingThread.daemon = True
            endingThread.start()
Пример #5
0
    def __init__(self, config, handler):
        url = 'ws://' + config['host'] + ':' + str(config['port']) + '/api/websocket'
        WebSocketClientFactory.__init__(self, url)

        self.handler = handler
        # Not sure why/whether _proto is needed?
        self._proto = None
        self.protocol.config = config
Пример #6
0
    def __init__(self, url):
        WebSocketClientFactory.__init__(self, url)

        self.protocolInstance = None
        self.tickGap = 5
        self.tickSetup()

        self.connect()
 def __init__(self, audio, options, callback, url=None, headers=None):
     WebSocketClientFactory.__init__(self, url=url, headers=headers)
     self.audio = audio
     self.options = options
     self.callback = callback
     self.SIX_SECONDS = 6
     self.openHandshakeTimeout = self.SIX_SECONDS
     self.closeHandshakeTimeout = self.SIX_SECONDS
Пример #8
0
    def __init__(self, address, port):
        WebSocketClientFactory.__init__(self,
                                        "ws://{0}:{1}".format(address, port),
                                        debug=self.debug,
                                        origin='null',
                                        protocols=["echo-protocol"])

        self.protocol = WSClientProtocol
Пример #9
0
	def __init__(self, path, debug, debugCodePaths=False):
		WebSocketClientFactory.__init__(self, path, debug=debug, debugCodePaths=False)
	
		try:
			self.sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
			self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
		except:
			log.msg("Error creating raw socket", logLevel=logging.WARN)
 def __init__(self, url):
   WebSocketClientFactory.__init__(self, url)
   
   self.protocolInstance = None
   self.tickGap = 5
   self.tickSetup()
   
   self.connect()
Пример #11
0
 def __init__(self, url, clientType, func):
     # url is a string in the format "ws://127.0.0.1:8008"
     # clientType is the string "/motor"
     # func is the handler function
     WebSocketClientFactory.__init__(self, url)
     self.connections = []
     self.clientType = clientType
     self.func = func
     self.connectionRefusedCount = 0
Пример #12
0
    def __init__(self, audioFd, summary, contentType, model, url=None, headers=None, debug=None):
        self.listeners = []
        WebSocketClientFactory.__init__(self, url=url, headers=headers, debug=debug)
        self.audioFd = audioFd
        self.summary = summary
        self.contentType = contentType
        self.model = model

        self.openHandshakeTimeout = 6
        self.closeHandshakeTimeout = 6
Пример #13
0
 def __init__(self, url, *args, **kwargs):
     DeepstreamFactory.__init__(self, url, *args, **kwargs)
     WebSocketClientFactory.__init__(
         self,
         url=url,
         origin=kwargs.pop('origin', None),
         protocols=kwargs.pop('protocols', None),
         useragent=kwargs.pop('useragent', None),
         headers=kwargs.pop('headers', None),
         proxy=kwargs.pop('proxy', None),
     )
Пример #14
0
    def __init__(self, exchange, data_processing):
        self.exchange = exchange

        WebSocketClientFactory.__init__(self,
                                        WsConfig[self.exchange]["ws_url"])

        self.logging = logging.getLogger(__name__)
        self.data_processing = data_processing
        self.proto = None
        self.lendingbook_list = []
        self.ticker_list = []
Пример #15
0
    def __init__(self, sessionhandler, *args, **kwargs):

        self.uid = kwargs.pop("uid")
        self.channel = kwargs.pop("grapevine_channel")
        self.sessionhandler = sessionhandler

        # self.noisy = False
        self.port = None
        self.bot = None

        WebSocketClientFactory.__init__(self, GRAPEVINE_URI, *args, **kwargs)
Пример #16
0
    def __init__(self, receiver, url, debug=True):
        """Constructor

        Args:
        receiver: The instance of IARIEventReceiver that will receive updates
        url: The URL to connect the WebSocket to
        debug: Optional. Enable greater debugging in WebSocketClientFactory.
               Defaults to True.
        """
        WebSocketClientFactory.__init__(self, url, debug=debug,
                                        protocols=['ari'])
        self.receiver = receiver
Пример #17
0
    def __init__(self, *args, **kwargs):
        self.base_client = None
        self.on_open = None
        self.on_error = None
        self.on_close = None
        self.on_connect = None
        self.on_reconnect = None
        self.on_reconnection_max_tries = None
        self.on_disconnect = None
        self.on_authenticated = None
        self.on_message = None
        self.on_message_get_exchanges = None
        self.on_message_instruments_on_search = None
        self.on_message_instruments = None
        self.on_message_last_quote = None
        self.on_message_last_quote_array = None
        self.on_message_snapshot_data = None
        self.on_message_historical_tick_data = None
        self.on_message_historical_ohlc_data = None
        self.on_message_instrument_types = None
        self.on_message_product = None
        self.on_message_expiry_dates = None
        self.on_message_option_types = None
        self.on_message_strike_prices = None
        self.on_message_account_limitations = None
        self.on_message_market_message = None
        self.on_message_exchange_message = None
        self.on_message_realtime_data = None
        self.on_message_realtime_snapshot_data = None

        WebSocketClientFactory.__init__(self, *args, **kwargs)

        def clientConnectionFailed(self, connector, reason):
            if self.on_reconnect:
                self.on_reconnect(self.retries)
            print("Client connection failed .. retrying ..")
            self.retry(connector)
            if self.maxRetries is not None and (self.retries >
                                                self.maxRetries):
                if self.on_reconnection_max_tries:
                    self.on_reconnection_max_tries()

        def clientConnectionLost(self, connector, reason):
            print("Client connection lost .. retrying ..")
            if self.retries > 0:
                if self.on_reconnect:
                    self.on_reconnect(self.retries)
            self.retry(connector)
            if self.maxRetries is not None and (self.retries >
                                                self.maxRetries):
                if self.on_reconnection_max_tries:
                    self.on_reconnection_max_tries()
Пример #18
0
    def __init__(self, url, clientType, func):
        '''
        Initializes the class

        Args:
            url (str): The url in the format "ws://127.0.0.1:8008"
            clientType (str): Example: "/motor"
            func (function): The handler function
        '''

        WebSocketClientFactory.__init__(self, url)
        self.connections = []
        self.clientType = clientType
        self.func = func
        self.connectionRefusedCount = 0
Пример #19
0
   def __init__(self, queue, summary, contentType, model, url=None, headers=None, debug=None):

      WebSocketClientFactory.__init__(self, url=url, headers=headers)   
      self.queue = queue
      self.summary = summary
      self.contentType = contentType
      self.model = model
      self.queueProto = Queue.Queue()

      self.openHandshakeTimeout = 10
      self.closeHandshakeTimeout = 10

      # start the thread that takes care of ending the reactor so the script can finish automatically (without ctrl+c)
      endingThread = threading.Thread(target=self.endReactor, args= ())
      endingThread.daemon = True
      endingThread.start()
    def __init__(self, threadID, uri, notificationQ):
        self.threadID = threadID
        self.uri = uri
        self.notification_q = notificationQ
        self.running = True
        WebSocketClientFactory.__init__(self,'ws://'+str(self.uri[7:]))
        threading.Thread.__init__(self)
        self.protocol = MyClientProtocol
        self.setProtocolOptions(openHandshakeTimeout=15)
        print self.uri
        address = self.uri[7:].split('/')[0]
        path =  self.uri[7:].split('/')[1:]

        ip = address.split(':')[0]
        port = address.split(':')[1]

        reactor.connectTCP(ip, int(port), self)
Пример #21
0
    def __init__(self, url: str, app, token: str, secure: bool):
        """
        Connect to the websocket
        :param url: URL to connect to
        :param app: Ref back to object that launched the WS
        :param token: Client token to to WS authentication
        :pram secure: is the server connection should be secure
        """
        if secure:
            protocol = "wss"
        else:
            protocol = "ws"
        WebSocketClientFactory.__init__(self,
                                        f"{protocol}://{url}",
                                        headers={"authorization": token})

        self.app = app
        self.client_protocol = None
Пример #22
0
    def __init__(self):
        logger.info('Initiating Slack RTM start request')
        data = api('rtm.start', no_latest=1)

        # Make the protocol a partial so that we can send the full info from rtm.start
        self.protocol = partial(Client, data)

        logger.info('creating WebSocketClientFactory with %s', data['url'])

        return WebSocketClientFactory.__init__(self, url=data['url'])
Пример #23
0
    def __init__(self):
        logger.info('Initiating Slack RTM start request')
        data = api('rtm.start', no_latest=1)

        # Make the protocol a partial so that we can send the full info from rtm.start
        self.protocol = partial(Client, data)

        logger.info('creating WebSocketClientFactory with %s', data['url'])

        return WebSocketClientFactory.__init__(self, url=data['url'])
Пример #24
0
    def __init__(self,
                 audioFd,
                 summary,
                 contentType,
                 model,
                 url=None,
                 headers=None,
                 debug=None):
        self.listeners = []
        WebSocketClientFactory.__init__(self,
                                        url=url,
                                        headers=headers,
                                        debug=debug)
        self.audioFd = audioFd
        self.summary = summary
        self.contentType = contentType
        self.model = model

        self.openHandshakeTimeout = 6
        self.closeHandshakeTimeout = 6
Пример #25
0
    def __init__(self, url):
        self.agent = autobahn.twisted.__ident__
        WebSocketClientFactory.__init__(self, url, useragent=self.agent)

        self.setProtocolOptions(failByDrop=False)  # spec conformance

        # enable permessage-deflate WebSocket protocol extension
        offers = [PerMessageDeflateOffer()]
        self.setProtocolOptions(perMessageCompressionOffers=offers)

        def accept(response):
            if isinstance(response, PerMessageDeflateResponse):
                return PerMessageDeflateResponseAccept(response)

        self.setProtocolOptions(perMessageCompressionAccept=accept)

        # setup client testee stuff
        self.endCaseId = None
        self.currentCaseId = 0
        self.updateReports = True
        self.resource = "/getCaseCount"
    def __init__(self, url):
        self.agent = autobahn.twisted.__ident__
        WebSocketClientFactory.__init__(self, url, useragent=self.agent)

        self.setProtocolOptions(failByDrop=False)  # spec conformance

        # enable permessage-deflate WebSocket protocol extension
        offers = [PerMessageDeflateOffer()]
        self.setProtocolOptions(perMessageCompressionOffers=offers)

        def accept(response):
            if isinstance(response, PerMessageDeflateResponse):
                return PerMessageDeflateResponseAccept(response)

        self.setProtocolOptions(perMessageCompressionAccept=accept)

        # setup client testee stuff
        self.endCaseId = None
        self.currentCaseId = 0
        self.updateReports = True
        self.resource = "/getCaseCount"
Пример #27
0
    def __init__(self,
                 queue,
                 base_model,
                 customization_weight,
                 custom=False,
                 url=None,
                 headers=None,
                 debug=None):

        WebSocketClientFactory.__init__(self, url=url, headers=headers)
        self.queue = queue
        self.base_model = base_model
        self.customization_weight = customization_weight
        self.custom = custom
        self.protocolQueue = Queue.Queue()

        self.closeHandshakeTimeout = 10  # Expected time for a closing handshake (seconds)
        self.openHandshakeTimeout = 10

        # Defining and starting the thread that ends the script automatically.
        endingThread = threading.Thread(target=self.endReactor, args=())
        endingThread.daemon = True  # Functions as a daemon in the background.
        endingThread.start()
Пример #28
0
 def __init__(self, addr, cam_port):
     WebSocketClientFactory.__init__(self,
                                     addr,
                                     headers={'camera_id': 'camera1'})
     print("Starting Camera")
     self.camera = WebcamVideoStream(src=0).start()
Пример #29
0
 def __init__(self, *args, payload=None, **kwargs):
     WebSocketClientFactory.__init__(self, *args, **kwargs)
     self.protocol_instance = None
     self.base_client = None
     self.payload = payload
Пример #30
0
	def __init__(self, address, port):
		WebSocketClientFactory.__init__(self, "ws://{0}:{1}".format(address, port), debug=self.debug, origin='null', protocols=["echo-protocol"])

		self.protocol = WSClientProtocol
Пример #31
0
 def __init__(self, *args, **kwargs):
     self.payload = kwargs.pop('payload')
     WebSocketClientFactory.__init__(self, *args, **kwargs)
     self.protocol_instance = None
     self.base_client = None
Пример #32
0
 def __init__(self, *args, **kwargs):
     clientManager = kwargs.pop("clientManager")
     self.clientManager = clientManager
     WebSocketClientFactory.__init__(self, *args, **kwargs)
Пример #33
0
 def __init__(self, url, command):
     WebSocketClientFactory.__init__(self, url)
     self.command = command
Пример #34
0
 def __init__(self, url, app):
     WebSocketClientFactory.__init__(self, url)
     self._app = app
     self._proto = None
 def __init__(self, *args, **kwargs):
     WebSocketClientFactory.__init__(self, *args, **kwargs)
     self.protocol_instance = None
     self.base_client = None
Пример #36
0
 def __init__(self, url):
     WebSocketClientFactory.__init__(self, url)
Пример #37
0
 def __init__(self, url):
     WebSocketClientFactory.__init__(self, url)
     self._protocols=[]
 def __init__(self, url, client):
     WebSocketClientFactory.__init__(self, url)
     self.client = client
     self.ws = WebSocket(self, self.client)
Пример #39
0
 def __init__(self, autobahn_status_push, *args, **kwargs):
     WebSocketClientFactory.__init__(self, *args, **kwargs)
     self.autobahn_status_push = autobahn_status_push
Пример #40
0
 def __init__(self, *args, **kwargs):
     clientManager = kwargs.pop("clientManager")
     self.clientManager = clientManager
     WebSocketClientFactory.__init__(self, *args, **kwargs)
Пример #41
0
    def __init__(self, *args, **kwargs):
        WebSocketClientFactory.__init__(self, *args, **kwargs)

        self.callbacks = {}
        self.register_callbacks()
Пример #42
0
 def __init__(self, *args, **kwargs):
     self.adapter = WebsocketClientAdapter()  # this is the adapter singleton
     WebSocketClientFactory.__init__(self, *args, **kwargs)
Пример #43
0
 def __init__(self, url, engine, broadcaster):
     BlockchainFactory.__init__(self, engine, broadcaster)
     WebSocketClientFactory.__init__(self, url=url)
Пример #44
0
 def __init__(self, url, app):
    WebSocketClientFactory.__init__(self, url)
    self._app = app
    self._proto = None
Пример #45
0
 def __init__(self, url, debug=False):
     WebSocketClientFactory.__init__(self,
                                     url,
                                     debug=debug,
                                     debugCodePaths=debug)
 def __init__(self, url, debug = False):
    WebSocketClientFactory.__init__(self, url, debug = debug, debugCodePaths = debug)
Пример #47
0
 def __init__(self,endpoint,reactor,irc=None):
     self.irc = irc
     self.reactor = reactor
     WebSocketClientFactory.__init__(self, endpoint, debug = False)