当前位置: 首页>>代码示例>>Python>>正文


Python WebSocketClientFactory.setProtocolOptions方法代码示例

本文整理汇总了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()
开发者ID:craigprice,项目名称:XTSM_1,代码行数:33,代码来源:PXI_Emulator.py

示例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"
开发者ID:gemelkelabs,项目名称:timing_system_software,代码行数:23,代码来源:pxi_emulator.py

示例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()
开发者ID:shuyunqi,项目名称:AutobahnPython,代码行数:32,代码来源:frame_based_client.py


注:本文中的autobahn.twisted.websocket.WebSocketClientFactory.setProtocolOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。