本文整理匯總了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
示例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)
示例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)
示例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)