当前位置: 首页>>代码示例>>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;未经允许,请勿转载。