本文整理汇总了Python中autobahn.twisted.websocket.WampWebSocketServerFactory.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python WampWebSocketServerFactory.__init__方法的具体用法?Python WampWebSocketServerFactory.__init__怎么用?Python WampWebSocketServerFactory.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WampWebSocketServerFactory
的用法示例。
在下文中一共展示了WampWebSocketServerFactory.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerFactory import __init__ [as 别名]
def __init__(self, factory, config, templates):
"""
Ctor.
:param factory: WAMP session factory.
:type factory: An instance of ..
:param config: Crossbar transport configuration.
:type config: dict
"""
options = config.get('options', {})
server = "Crossbar/{}".format(crossbar.__version__)
externalPort = options.get('external_port', None)
WampWebSocketServerFactory.__init__(self,
factory,
url = config.get('url', None),
server = server,
externalPort = externalPort,
debug = config.get('debug', False))
## transport configuration
self._config = config
## Jinja2 templates for 404 etc
self._templates = templates
## cookie tracking
if 'cookie' in config:
self._cookies = {}
## set WebSocket options
set_websocket_options(self, options)
示例2: __init__
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerFactory import __init__ [as 别名]
def __init__(self, factory, *args, **kwargs):
self._connection_count = 0
self._timeout = kwargs['timeout']
self._reaper = reactor.callLater(self._timeout, lambda: reactor.stop())
del kwargs['timeout']
WampWebSocketServerFactory.__init__(self, factory, *args, **kwargs)
WampWebSocketServerFactory.protocol = TimeoutWampWebSocketServerProtocol
示例3: __init__
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerFactory import __init__ [as 别名]
def __init__(self, factory, cbdir, config, templates):
"""
Ctor.
:param factory: WAMP session factory.
:type factory: An instance of ..
:param cbdir: The Crossbar.io node directory.
:type cbdir: str
:param config: Crossbar transport configuration.
:type config: dict
"""
self.debug = config.get('debug', False)
self.debug_traffic = config.get('debug_traffic', False)
options = config.get('options', {})
server = "Crossbar/{}".format(crossbar.__version__)
externalPort = options.get('external_port', None)
# explicit list of WAMP serializers
#
if 'serializers' in config:
serializers = []
sers = set(config['serializers'])
if 'json' in sers:
# try JSON WAMP serializer
try:
from autobahn.wamp.serializer import JsonSerializer
serializers.append(JsonSerializer())
except ImportError:
print("Warning: could not load WAMP-JSON serializer")
else:
sers.discard('json')
if 'msgpack' in sers:
# try MsgPack WAMP serializer
try:
from autobahn.wamp.serializer import MsgPackSerializer
serializers.append(MsgPackSerializer())
except ImportError:
print("Warning: could not load WAMP-MsgPack serializer")
else:
sers.discard('msgpack')
if not serializers:
raise Exception("no valid WAMP serializers specified")
if len(sers) > 0:
raise Exception("invalid WAMP serializers specified: {}".format(sers))
else:
serializers = None
WampWebSocketServerFactory.__init__(self,
factory,
serializers=serializers,
url=config.get('url', None),
server=server,
externalPort=externalPort,
debug=self.debug,
debug_wamp=self.debug)
# Crossbar.io node directory
self._cbdir = cbdir
# transport configuration
self._config = config
# Jinja2 templates for 404 etc
self._templates = templates
# cookie tracking
if 'cookie' in config:
if 'database' in config['cookie']:
dbfile = os.path.abspath(os.path.join(self._cbdir, config['cookie']['database']))
self._cookiestore = PersistentCookieStore(dbfile, config['cookie'])
log.msg("Persistent cookie store active: {}".format(dbfile))
else:
self._cookiestore = CookieStore(config['cookie'])
log.msg("Transient cookie store active.")
else:
self._cookiestore = None
# set WebSocket options
set_websocket_options(self, options)
示例4: __init__
# 需要导入模块: from autobahn.twisted.websocket import WampWebSocketServerFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WampWebSocketServerFactory import __init__ [as 别名]
def __init__(self, factory, config, templates):
"""
Ctor.
:param factory: WAMP session factory.
:type factory: An instance of ..
:param config: Crossbar transport configuration.
:type config: dict
"""
options = config.get('options', {})
server = "Crossbar/{}".format(crossbar.__version__)
externalPort = options.get('external_port', None)
## explicit list of WAMP serializers
##
if 'serializers' in options:
serializers = []
sers = set(options['serializers'])
if 'json' in sers:
## try JSON WAMP serializer
try:
from autobahn.wamp.serializer import JsonSerializer
serializers.append(JsonSerializer())
except ImportError:
print("Warning: could not load WAMP-JSON serializer")
else:
sers.discard('json')
if 'msgpack' in sers:
## try MsgPack WAMP serializer
try:
from autobahn.wamp.serializer import MsgPackSerializer
serializers.append(MsgPackSerializer())
except ImportError:
print("Warning: could not load WAMP-MsgPack serializer")
else:
sers.discard('msgpack')
if not serializers:
raise Exception("no valid WAMP serializers specified")
if len(sers) > 0:
raise Exception("invalid WAMP serializers specified: {}".format(sers))
else:
serializers = None
WampWebSocketServerFactory.__init__(self,
factory,
serializers = serializers,
url = config.get('url', None),
server = server,
externalPort = externalPort,
debug = config.get('debug', False))
## transport configuration
self._config = config
## Jinja2 templates for 404 etc
self._templates = templates
## cookie tracking
if 'cookie' in config:
self._cookies = {}
## set WebSocket options
set_websocket_options(self, options)