本文整理汇总了Python中autobahn.wamp.WampServerFactory类的典型用法代码示例。如果您正苦于以下问题:Python WampServerFactory类的具体用法?Python WampServerFactory怎么用?Python WampServerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WampServerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, port = 9000, debug = False):
self.port = port
self.debug = debug
factory = WampServerFactory("ws://localhost:%d" % self.port, debug = self.debug)
factory.protocol = LabspiralServerProtocol
factory.setProtocolOptions(allowHixie76 = True) # needed if Hixie76 is to be supported
self.factory = factory
示例2: startFactory
def startFactory(self):
WampServerFactory.startFactory(self)
log.msg("AdminWebSocketFactory started [speaking %s]" % self.protocols)
log.msg("debugWamp: %s" % self.debugWamp)
log.msg("debugApp: %s" % self.debugApp)
self.updateAvailable = {"update-available": False}
self.autocheckForUpdates()
示例3: __init__
def __init__(self, url, debug = False):
WampServerFactory.__init__(self, url, debugWamp = debug)
self.setProtocolOptions(allowHixie76 = True)
## the key-value store resides on the factory object, since it is to
## be shared among all client connections
self.keyvalue = KeyValue("keyvalue.dat")
decimal.getcontext().prec = 20
示例4: __init__
def __init__(self, url, dbpool, services):
WampServerFactory.__init__(self, url, debug = False, debugWamp = False)
self.dbpool = dbpool
self.services = services
self.stats = {'ws-connections': 0,
'ws-publications': 0,
'ws-dispatched-success': 0,
'ws-dispatched-failed': 0}
self.statsChanged = False
self.trackingCookies = {}
示例5: WebSocketServer
class WebSocketServer():
server = None
def __init__(self, port, debug):
if debug:
log.startLogging(sys.stdout)
self.server = WampServerFactory("ws://localhost:"+ str(port), debug)
self.server.protocol = LogeeProtocol
listenWS(self.server)
def broadcast(self, topic, message):
self.server.dispatch(topic, message)
示例6: __init__
def __init__(self, config):
self.config = config
WampServerFactory.__init__(self, config.wsuri, debugWamp = config.debug)
self.setProtocolOptions(failByDrop = False)
if config.skiputf8validate:
self.setProtocolOptions(utf8validateIncoming = False)
if config.allowunmasked:
self.setProtocolOptions(requireMaskedClientFrames = False)
print "Load/Latency Broker listening on %s [skiputf8validate = %s, allowunmasked = %s]" % (config.wsuri, config.skiputf8validate, config.allowunmasked)
示例7: __init__
def __init__(self, port, debug):
if debug:
log.startLogging(sys.stdout)
self.server = WampServerFactory("ws://localhost:"+ str(port), debug)
self.server.protocol = LogeeProtocol
listenWS(self.server)
示例8: runServer
def runServer():
if len(sys.argv) > 1 and sys.argv[1] == 'debug':
log.startLogging(sys.stdout)
debug = True
else:
debug = False
factory = WampServerFactory("ws://localhost:9000", debug=False, debugCodePaths=False, debugWamp=debug, debugApp=False)
factory.protocol = AppServerProtocol
factory.setProtocolOptions(allowHixie76 = True)
listenWS(factory)
webdir = File(".")
web = Site(webdir)
reactor.listenTCP(8080, web)
reactor.run(installSignalHandlers=0)
示例9: dispatch
def dispatch(self, topicUri, event, exclude = [], eligible = None):
"""
Normal dispatch from a WAMP client publish.
"""
d = WampServerFactory.dispatch(self, topicUri, event, exclude, eligible)
d.addCallback(self.logNormalDispatch)
return d
示例10: dispatchHubEvent
def dispatchHubEvent(self, topicuri, event, exclude = [], eligible = None):
"""
Dispatch from a REST API Push.
"""
if exclude:
exclude = self.sessionIdsToProtos(exclude)
if eligible:
eligible = self.sessionIdsToProtos(eligible)
return WampServerFactory.dispatch(self, topicuri, event, exclude, eligible)
示例11: __init__
def __init__(self, config):
self.config = config
WampServerFactory.__init__(self, config.wsuri, debugWamp = config.debug)
self.setProtocolOptions(failByDrop = False)
if config.skiputf8validate:
self.setProtocolOptions(utf8validateIncoming = False)
if config.allowunmasked:
self.setProtocolOptions(requireMaskedClientFrames = False)
self.connectedClients = set()
print "Load/Latency Broker listening on %s [skiputf8validate = %s, allowunmasked = %s]" % (config.wsuri, config.skiputf8validate, config.allowunmasked)
def printstats():
print "%d clients connected" % len(self.connectedClients)
reactor.callLater(1, printstats)
printstats()
示例12: run_server
def run_server ():
reactor.listenTCP(8789, pb.PBServerFactory(ExperimentMarshal()))
log.msg("PB listening on port 8789")
factory = WampServerFactory("ws://localhost:9000")
factory.protocol = LabspiralServerProtocol
listenWS(factory)
log.msg("WS listening on port 9000")
ExperimentMarshal.publish = factory.dispatch
root = resource.Resource()
root.putChild("", Root())
root.putChild("experiments", ExperimentList())
root.putChild("resources", static.File("resources"))
site = server.Site(root)
reactor.listenTCP(8001, site)
log.msg("HTTP listening on port 8001")
reactor.run()
log.msg("Server stopped")
示例13: runwamp
def runwamp(logfile=None, debug=True):
if logfile is None:
log.startLogging(sys.stdout)
'''
factory = WampServerFactory("ws://%s:9000" % socket.gethostname(),
debugWamp=debug)
'''
factory = ""
host_name = socket.gethostname()
if host_name == 'ip-172-31-29-49':
factory = WampServerFactory("ws://oposod.com:9000", debugWamp=None)
else:
factory = WampServerFactory("ws://localhost:9000", debugWamp=debug)
factory.protocol = PubSubServer1
factory.setProtocolOptions(allowHixie76=True)
listenWS(factory)
webdir = File(".")
web = Site(webdir)
reactor.listenTCP(9090, web)
reactor.run()
示例14: DirWatchServerProtocol
from twisted.web.static import File
from autobahn.twisted.websocket import listenWS
from autobahn.wamp import WampServerFactory, \
WampServerProtocol
class DirWatchServerProtocol(WampServerProtocol):
def onSessionOpen(self):
## register a URI and all URIs having the string as prefix as PubSub topic
self.registerForPubSub("http://dirwatch.autobahn.ws", True)
if __name__ == '__main__':
log.startLogging(sys.stdout)
debug = len(sys.argv) > 1 and sys.argv[1] == 'debug'
factory = WampServerFactory("ws://localhost:9000", debugWamp = debug)
factory.protocol = DirWatchServerProtocol
factory.setProtocolOptions(allowHixie76 = True)
listenWS(factory)
webdir = File(".")
web = Site(webdir)
reactor.listenTCP(8080, web)
reactor.run()
示例15: __init__
def __init__(self, url, dbpool, services):
WampServerFactory.__init__(self, url, debugApp = False)
self.dbpool = dbpool
self.services = services
self.restartRequired = False