本文整理汇总了Python中autobahn.twisted.websocket.WebSocketClientFactory.setProtocolOptions方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketClientFactory.setProtocolOptions方法的具体用法?Python WebSocketClientFactory.setProtocolOptions怎么用?Python WebSocketClientFactory.setProtocolOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WebSocketClientFactory
的用法示例。
在下文中一共展示了WebSocketClientFactory.setProtocolOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import setProtocolOptions [as 别名]
def main():
global command_library
command_library = CommandLibrary()
address = "ws://" + 'localhost'
keyboard = Keyboard_Input()
stdio.StandardIO(keyboard)
multicast = reactor.listenMulticast(udpbport,
MulticastProtocol(),
listenMultiple=True)
factory = WebSocketClientFactory(address + ":8084", debug = False)
factory.setProtocolOptions(failByDrop=False)
factory.protocol = MyClientProtocol
#command_library.request_active_xtsm()
try:
connectWS(factory)
command_library.factory = factory
command_library.multicast = multicast
factory.command_library = command_library
print "........................WS Server Running......................."
except twisted.internet.error.CannotListenError:
print "Can't listen"
#server_shutdown()
global tcp
tcp = PXI_Emulator_TCP()
reactor.run()
示例2: main
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import setProtocolOptions [as 别名]
def main():
global command_library
command_library = CommandLibrary()
address = "ws://" + 'localhost'
keyboard = Keyboard_Input()
stdio.StandardIO(keyboard)
multicast = reactor.listenMulticast(udpbport,
MulticastProtocol(),
listenMultiple=True)
factory = WebSocketClientFactory(address + ":8084", debug = False)
factory.setProtocolOptions(failByDrop=False)
factory.protocol = MyClientProtocol
try:
connectWS(factory)
command_library.factory = factory
command_library.multicast = multicast
factory.command_library = command_library
except twisted.internet.error.CannotListenError:
print "Can't listen"
示例3: onClose
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import setProtocolOptions [as 别名]
self.sendClose()
def onClose(self, wasClean, code, reason):
reactor.stop()
if __name__ == '__main__':
factory = WebSocketClientFactory("ws://127.0.0.1:9000")
factory.protocol = FrameBasedHashClientProtocol
enableCompression = False
if enableCompression:
from autobahn.websocket.compress import PerMessageDeflateOffer, \
PerMessageDeflateResponse, \
PerMessageDeflateResponseAccept
# The extensions offered to the server ..
offers = [PerMessageDeflateOffer()]
factory.setProtocolOptions(perMessageCompressionOffers=offers)
# Function to accept responses from the server ..
def accept(response):
if isinstance(response, PerMessageDeflateResponse):
return PerMessageDeflateResponseAccept(response)
factory.setProtocolOptions(perMessageCompressionAccept=accept)
connectWS(factory)
reactor.run()