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


Python WampServerFactory.protocol方法代码示例

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


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

示例1: __init__

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
	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
开发者ID:rasata,项目名称:octopus,代码行数:10,代码来源:server.py

示例2: runServer

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
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)
开发者ID:DamnedFacts,项目名称:Vernacular,代码行数:18,代码来源:server.py

示例3: run_server

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
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")
开发者ID:rasata,项目名称:octopus,代码行数:24,代码来源:server.py

示例4: runwamp

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
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()
开发者ID:am1ty9d9v,项目名称:oposod,代码行数:26,代码来源:tasks.py

示例5: WampServerFactory

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
        if sx > bx:
            scale_factor = bx/float(ix)
            sx = bx
            sy = scale_factor * iy
        else:
            sy = by

    return pygame.transform.smoothscale(img, (int(sx),int(sy)))

# log.startLogging(sys.stdout)
log.startLogging(open('log.txt','w'))
print "Darrell's toy photo frame"

#  Setup RPC
factory = WampServerFactory("ws://localhost:9000")
factory.protocol = RpcServerProtocol
listenWS(factory)

# Initial pygame and the screen 
pygame.init()
w = pygame.display.Info().current_w
h= pygame.display.Info().current_h
print "w: ", w, "h: ", h
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
pygame.mouse.set_visible(0)
screen = pygame.display.set_mode(size,pygame.FULLSCREEN)

# Create and Fill background
background = pygame.Surface(screen.get_size())
background = background.convert()  # This is cargo cult.. I don't know why it's here.
background.fill(bgcolor)
开发者ID:golliher,项目名称:hpf,代码行数:33,代码来源:photoframe.py

示例6: connectionLost

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
   def connectionLost(self, reason):
      """
      When connection is gone (i.e. client close window, navigated
      away from the page), stop the model timer, which holds last
      reference to model, and delete the model
      """
      WampServerProtocol.connectionLost(self, reason)

      self.processModel.timer.stop()
      self.processModel = None


if __name__ == '__main__':

   if len(sys.argv) > 1 and sys.argv[1] == 'debug':
      log.startLogging(sys.stdout)
      debug = True
   else:
      debug = False

   factory = WampServerFactory("ws://localhost:9001", debugWamp = debug)
   factory.protocol = ProcessMonitorServerProtocol
   factory.setProtocolOptions(allowHixie76 = True)
   listenWS(factory)

   webdir = File(".")
   web = Site(webdir)
   reactor.listenTCP(8081, web)

   reactor.run()
开发者ID:vminakov,项目名称:system-monitor,代码行数:32,代码来源:server_process.py

示例7: connectionLost

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
   def connectionLost(self, reason):
      """
      When connection is gone (i.e. client close window, navigated
      away from the page), stop the model timer, which holds last
      reference to model, and delete the model
      """
      WampServerProtocol.connectionLost(self, reason)
      self.infoModel = None



if __name__ == '__main__':

   if len(sys.argv) > 1 and sys.argv[1] == 'debug':
      log.startLogging(sys.stdout)
      debug = True
   else:
      debug = False

   factory = WampServerFactory("ws://localhost:9000", debugWamp = debug)
   factory.protocol = SystemInfoServerProtocol
   factory.setProtocolOptions(allowHixie76 = True)
   listenWS(factory)

   webdir = File(".")
   web = Site(webdir)
   reactor.listenTCP(8080, web)

   reactor.run()
开发者ID:vminakov,项目名称:system-monitor,代码行数:31,代码来源:server_info.py

示例8: getIfaces

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
   @exportRpc
   def getIfaces(self):
      """
      Return names of all available network interfaces
      """
      ifaces = psutil.network_io_counters(pernic=True).keys()
      ifaces.append('total')

      return ifaces


if __name__ == '__main__':

   if len(sys.argv) > 1 and sys.argv[1] == 'debug':
      log.startLogging(sys.stdout)
      debug = True
   else:
      debug = False

   factory = WampServerFactory("ws://localhost:9004", debugWamp = debug)
   factory.protocol = NetworkInfoServerProtocol
   factory.setProtocolOptions(allowHixie76 = True)
   listenWS(factory)

   webdir = File(".")
   web = Site(webdir)
   reactor.listenTCP(8084, web)

   reactor.run()
开发者ID:vminakov,项目名称:system-monitor,代码行数:31,代码来源:server_network.py

示例9: onAuthenticated

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
        return threads.deferToThread( thunk )

    def onAuthenticated( self, authKey, perms ):
        peer = self.peerstr
        if authKey is None:
            msg = "Anonymous connected from %s" % peer
        else:
            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 )
开发者ID:dkolbly,项目名称:flowman,代码行数:33,代码来源:webapp.py

示例10: RpcServerProtocol

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
#!/usr/bin/env python2.7 -u -Wall

import sys

from twisted.internet import reactor
from twisted.python import log
from autobahn.wamp import WampServerFactory, \
                          WampServerProtocol, \
                          exportRpc
from autobahn.websocket import listenWS

class RpcServerProtocol(WampServerProtocol):

   @exportRpc
   def add(self, x, y):
      return x + y

   def onSessionOpen(self):
      self.registerForPubSub("/mpd/test")

if __name__ == '__main__':
   factory = WampServerFactory("ws://localhost:9001", debug=True)
   factory.protocol = WampServerProtocol
   log.startLogging(sys.stdout)
   listenWS(factory)
   print "Here we go"
   sys.stdout.flush() # flush the line so that tests know we're up
   sys.stderr.flush()
   reactor.run()
开发者ID:ewollesen,项目名称:ruby-wamp-client,代码行数:31,代码来源:wamp_server.py

示例11: endpoints

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
        ## register PubSub topics from the auth permissions
        self.registerForPubSubFromPermissions(perms["permissions"])

        ## register RPC endpoints (for now do that manually, keep in sync with perms)
        if authKey is None:
            self.registerForRpc(self, "http://example.com/procedures/", [MyServerProtocol.getUsers])

    @exportRpc("getusers")
    def getUsers(self):
        return self.USERS.keys()


if __name__ == "__main__":

    if len(sys.argv) > 1 and sys.argv[1] == "debug":
        log.startLogging(sys.stdout)
        debug = True
    else:
        debug = False

    factory = WampServerFactory("ws://localhost:9000", debugWamp=debug)
    factory.protocol = DbusServerProtocol
    listenWS(factory)

    webdir = File(".")
    web = Site(webdir)
    reactor.listenTCP(8080, web)

    reactor.run()
开发者ID:gijs,项目名称:AutobahnPython,代码行数:31,代码来源:server.py

示例12: PubSubServer1

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
from autobahn.wamp import WampServerFactory, \
                          WampServerProtocol


class PubSubServer1(WampServerProtocol):

   def onSessionOpen(self):

      ## register a single, fixed URI as PubSub topic
      self.registerForPubSub("http://example.com/simple")

      ## register a URI and all URIs having the string as prefix as PubSub topic
      self.registerForPubSub("http://example.com/event#", 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 = PubSubServer1
   factory.setProtocolOptions(allowHixie76 = True)
   listenWS(factory)

   webdir = File(".")
   web = Site(webdir)
   reactor.listenTCP(8080, web)

   reactor.run()
开发者ID:Aerobota,项目名称:autobahn_rce,代码行数:32,代码来源:server.py

示例13: dataReceived

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
    def dataReceived(self, data):
        self.resetTimeout()
        print len(data)
        if len(data) == 11:
            packet = Packet(data)
            print packet
            self._publish(packet.toDict())
            reactor.callLater(0.1, self.sendCMD, 'GET')
        else:
           log.msg("Received Gargabe")
           log.msg("LEN: %s " % len(data))
           log.msg(data)

    def lineReceived(self, line):
        log.msg("Line Received")
        log.msg(line)


if __name__ == '__main__':
    ##Setup Server
    wampServerFactory = WampServerFactory("ws://localhost:9000")
    wampServerFactory.protocol = TSPublisher
    listenWS(wampServerFactory)

    ##Setup Client
    wampClientFactory = WampClientFactory("ws://localhost:9000")
    wampClientFactory.protocol = TSClient
    connectWS(wampClientFactory)

    reactor.run()
开发者ID:klemmster,项目名称:tsd-live,代码行数:32,代码来源:readTSD.py

示例14: state

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
    @exportRpc("state")
    def state(self):
        return running

if PI:
    def cleanup():
        GPIO.output(12, False)
        GPIO.cleanup()

    atexit.register(cleanup)

if __name__ == '__main__':
#    if len(sys.argv) > 1 and sys.argv[1] == 'debug':
#        log.startLogging(sys.stdout)
#        debug = True
#    else:
#        debug = False
    
    log.startLogging(sys.stdout)
    
    factory = WampServerFactory("ws://localhost:9000", debugWamp=True)
    factory.protocol = ScarefrogServerProtocol
    factory.setProtocolOptions(allowHixie76=True)
    listenWS(factory)
    
    webdir = File("www")
    web = Site(webdir)
    reactor.listenTCP(8080, web)

    reactor.run()
开发者ID:skyborla,项目名称:scarefrog,代码行数:32,代码来源:server.py

示例15: PubSubHandlers

# 需要导入模块: from autobahn.wamp import WampServerFactory [as 别名]
# 或者: from autobahn.wamp.WampServerFactory import protocol [as 别名]
        self.registerForPubSub(_url('players'))
        
        self.pubsub = PubSubHandlers(self)
        self.registerHandlerForPubSub(self.pubsub, BASE_URL)

    def connectionLost(self, reason):
        self.pubsub.send_users_list(exclude=[self])
        WampServerProtocol.connectionLost(self, reason)


class EatBulletServerFactory(WampServerFactory):

    def __init__(self, url, debug=False, debugCodePaths=False, debugWamp=False, debugApp=False, externalPort=None):
        self.games = []
        WampServerFactory.__init__(self, url, debug=debug, debugCodePaths=debugCodePaths, externalPort=externalPort)


if __name__ == '__main__':

    log.startLogging(sys.stdout)
    
    factory = WampServerFactory('ws://localhost:9000', debugWamp=True)
    factory.protocol = EatBulletServerProtocol
    listenWS(factory)

    webdir = File(".")
    web = Site(webdir)
    reactor.listenTCP(8080, web)
    
    reactor.run()
开发者ID:SunnyMagadan,项目名称:eatbullet,代码行数:32,代码来源:server.py


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