Python autobahn.twisted.websocket.connectWS() Examples

The following are 4 code examples of autobahn.twisted.websocket.connectWS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module autobahn.twisted.websocket , or try the search function .
Example #1
Source File: get_ibm_asr_results.py    From deep_disfluency with MIT License 6 votes vote down vote up
def onClose(self, wasClean, code, reason):

        print("onClose")
        print("WebSocket connection closed: {0}".format(reason), "code: ", code, "clean: ", wasClean, "reason: ", reason)
        self.summary[self.uttNumber]['status']['code'] = code
        self.summary[self.uttNumber]['status']['reason'] = reason
      
        # create a new WebSocket connection if there are still utterances in the queue that need to be processed
        self.queue.task_done()

        if self.factory.prepareUtterance() == False:
            return

        # SSL client context: default
        if self.factory.isSecure:
            contextFactory = ssl.ClientContextFactory()
        else:
            contextFactory = None
        connectWS(self.factory, contextFactory)

# function to check that a value is a positive integer 
Example #2
Source File: cxbr.py    From Paradrop with Apache License 2.0 5 votes vote down vote up
def start(klass, address, pdid, realm='paradrop', start_reactor=False,
              debug=False, extra=None, reconnect=True):
        '''
        Creates a new instance of this session and attaches it to the router
        at the given address and realm.

        reconnect: The session will attempt to reconnect on connection failure
            and continue trying indefinitely.
        '''
        # Enable log messages of autobahn for debugging
        #import txaio
        #txaio.start_logging()

        dee = Deferred()

        component_config = ComponentConfig(realm=u''+realm, extra=u''+pdid)
        session_factory = BaseSessionFactory(config=component_config, deferred=dee)
        session_factory.session = klass

        transport_factory = BaseClientFactory(session_factory, url=address)
        if not reconnect:
            transport_factory.maxRetries = 0
        transport_factory.setProtocolOptions(autoPingInterval=8., autoPingTimeout=4.,)
        context_factory = ClientContextFactory()
        websocket.connectWS(transport_factory, context_factory)

        if start_reactor:
            reactor.run()

        return dee

        # This the the recommended way to start the WAMP component,
        # but it is friendly to customize the component
        #runner = ApplicationRunner(url=u''+address, realm=u''+realm)
        #return runner.run(klass, start_reactor=start_reactor, auto_reconnect=reconnect) 
Example #3
Source File: comm_autobahn.py    From roslibpy with MIT License 5 votes vote down vote up
def connect(self):
        """Establish WebSocket connection to the ROS server defined for this factory."""
        self.connector = connectWS(self) 
Example #4
Source File: get_ibm_asr_results.py    From deep_disfluency with MIT License 5 votes vote down vote up
def endReactor(self):

        self.queue.join()
        print "about to stop the reactor!"
        reactor.stop()

    # this function gets called every time connectWS is called (once per WebSocket connection/session)