本文整理汇总了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')