當前位置: 首頁>>代碼示例>>Python>>正文


Python websocket.connectWS方法代碼示例

本文整理匯總了Python中autobahn.twisted.websocket.connectWS方法的典型用法代碼示例。如果您正苦於以下問題:Python websocket.connectWS方法的具體用法?Python websocket.connectWS怎麽用?Python websocket.connectWS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在autobahn.twisted.websocket的用法示例。


在下文中一共展示了websocket.connectWS方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: onClose

# 需要導入模塊: from autobahn.twisted import websocket [as 別名]
# 或者: from autobahn.twisted.websocket import connectWS [as 別名]
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 
開發者ID:clp-research,項目名稱:deep_disfluency,代碼行數:23,代碼來源:get_ibm_asr_results.py

示例2: start

# 需要導入模塊: from autobahn.twisted import websocket [as 別名]
# 或者: from autobahn.twisted.websocket import connectWS [as 別名]
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) 
開發者ID:ParadropLabs,項目名稱:Paradrop,代碼行數:37,代碼來源:cxbr.py

示例3: connect

# 需要導入模塊: from autobahn.twisted import websocket [as 別名]
# 或者: from autobahn.twisted.websocket import connectWS [as 別名]
def connect(self):
        """Establish WebSocket connection to the ROS server defined for this factory."""
        self.connector = connectWS(self) 
開發者ID:gramaziokohler,項目名稱:roslibpy,代碼行數:5,代碼來源:comm_autobahn.py

示例4: endReactor

# 需要導入模塊: from autobahn.twisted import websocket [as 別名]
# 或者: from autobahn.twisted.websocket import connectWS [as 別名]
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) 
開發者ID:clp-research,項目名稱:deep_disfluency,代碼行數:9,代碼來源:get_ibm_asr_results.py


注:本文中的autobahn.twisted.websocket.connectWS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。