本文整理汇总了Python中autobahn.twisted.websocket.WebSocketClientFactory.noisy方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketClientFactory.noisy方法的具体用法?Python WebSocketClientFactory.noisy怎么用?Python WebSocketClientFactory.noisy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WebSocketClientFactory
的用法示例。
在下文中一共展示了WebSocketClientFactory.noisy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import noisy [as 别名]
def connect(self):
factory = WebSocketClientFactory("ws://%s:%s/ws/" % (self.host, self.port), debug=False)
factory.noisy = True
factory.protocol = MdcloudWebsocketClientProtocol
factory.protocol.client = self
self.onc = defer.Deferred()
key_path = os.path.expanduser('~/.mcloud/%s.key' % self.host)
crt_path = os.path.expanduser('~/.mcloud/%s.crt' % self.host)
class NoKeyError(Exception):
pass
try:
if not self.no_ssl and self.host != '127.0.0.1':
if not os.path.exists(key_path):
raise NoKeyError('Key for server "%s" not found in file "%s"' % (self.host, key_path))
if not os.path.exists(crt_path):
raise NoKeyError('Key for server "%s" not found in file "%s"' % (self.host, crt_path))
from mcloud.ssl import CtxFactory
reactor.connectSSL(self.host, self.port, factory, CtxFactory(key_path, crt_path))
else:
reactor.connectTCP(self.host, self.port, factory)
except NoKeyError:
print 'No key found - fallback to no-ssl'
reactor.connectTCP(self.host, self.port, factory)
return self.onc