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
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)
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()
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()
self.registerForPubSub("http://example.com/event#", True, pubsub=WampServerProtocol.SUBSCRIBE) #reactor.callLater(5, self.sendEvent) #def sendEvent(self, event): # self.dispatch("http://example.com/simple", event) if __name__ == '__main__': log.startLogging(sys.stdout) # websocket stuff debug = len(sys.argv) > 1 and sys.argv[1] == 'debug' factory = WampServerFactory("ws://0.0.0.0:9000", debugWamp=debug) factory.protocol = PubSubServer factory.setProtocolOptions(allowHixie76=True) listenWS(factory) # rabbitmq stuff parameters = pika.ConnectionParameters() cc = protocol.ClientCreator(reactor, twisted_connection.TwistedProtocolConnection, parameters) d = cc.connectTCP('localhost', 5672) d.addCallback(lambda protocol: protocol.ready) pika_consumer = PikaConsumer(factory) d.addCallback(pika_consumer.run) reactor.run()
from autobahn.websocket import listenWS from autobahn.wamp import WampServerFactory, \ WampServerProtocol class PubSubServer1(WampServerProtocol): def onSessionOpen(self): ## register a single, fixed URI as PubSub topic self.registerForPubSub("http://leddimmer.unserHaus.name/event") ## register a URI and all URIs having the string as prefix as PubSub topic self.registerForPubSub("http://leddimmer.unserHaus.name/event#", True) if __name__ == '__main__': log.startLogging(sys.stdout) debug = len(sys.argv) > 1 and sys.argv[1] == 'debug' debug = True factory = WampServerFactory("ws://localhost:9000", debugWamp=debug) factory.protocol = PubSubServer1 factory.setProtocolOptions(allowHixie76=True, tcpNoDelay=True) listenWS(factory) webdir = File(".") web = Site(webdir) reactor.listenTCP(8080, web) reactor.run()
msg = "%s connected from %s" % (authKey,peer) self.currentUser = authKey self.currentRole = 'default' deferLater( reactor, 1, lambda: NotificationProtocol.notify(msg) ) f = WampServerFactory( "ws://localhost:2001", debugWamp=True ) f.protocol = WorkflowProtocol # # allowHixie76=True is required in order to work with iOS and Safari, # but this is insecure # # see https://groups.google.com/forum/?fromgroups=#!topic/autobahnws/wOEU3Bvp4HQ f.setProtocolOptions( allowHixie76=True ) listenWS(f) NotificationProtocol.start() from twisted.python import log reactor.listenTCP( 2000, Site( root ) ) import sys log.startLogging( sys.stdout ) log.msg( "starting" ) from application import MODULE app = MODULE.Application() app.start() reactor.run()