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


Python WebSocketServerFactory.setProtocolOptions方法代码示例

本文整理汇总了Python中autobahn.asyncio.websocket.WebSocketServerFactory.setProtocolOptions方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerFactory.setProtocolOptions方法的具体用法?Python WebSocketServerFactory.setProtocolOptions怎么用?Python WebSocketServerFactory.setProtocolOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autobahn.asyncio.websocket.WebSocketServerFactory的用法示例。


在下文中一共展示了WebSocketServerFactory.setProtocolOptions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AutobahnLoultServer

# 需要导入模块: from autobahn.asyncio.websocket import WebSocketServerFactory [as 别名]
# 或者: from autobahn.asyncio.websocket.WebSocketServerFactory import setProtocolOptions [as 别名]
        loult_state.can_ban = True
    except BanFail:
        loult_state.can_ban = False
        logger.warning("nft command dosen't work; bans are disabled.")


    class AutobahnLoultServer(LoultServer, WebSocketServerProtocol):
        loult_state = loult_state
        client_logger = logging.getLogger('client')


    factory = WebSocketServerFactory(server='Lou.lt/NG') # 'ws://127.0.0.1:9000',
    factory.protocol = AutobahnLoultServer
    # Allow 4KiB max size for messages, in a single frame.
    factory.setProtocolOptions(
            autoPingInterval=60,
            autoPingTimeout=30,
        )

    coro = loop.create_server(factory, '127.0.0.1', 9000)
    scheduler_task = ensure_future(scheduler.start())
    server = loop.run_until_complete(gather(coro, scheduler_task))

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        logger.info('Shutting down all connections...')
        for client in chain.from_iterable((channel.clients for channel in loult_state.chans.values())):
            client.sendClose(code=1000, reason='Server shutting down.')
        loop.close()
        print('aplse')
开发者ID:4577,项目名称:loult-ng,代码行数:33,代码来源:poke.py


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