Slide 11
Slide 11 text
Crossbar: Networking for
Applications
• Crossbar is a WAMP router
• WAMP? WebSockets? Autobahn?
from autobahn.twisted.util import sleep
from twisted.internet.defer import inlineCallbacks
from autobahn import wamp
from autobahn.twisted.wamp import ApplicationSession
class ExamplePython2Component(ApplicationSession):
@wamp.register(u'com.demo.add')
def add(x, y)
return x + y
@inlineCallbacks
def onJoin(self, details):
yield self.register(self)
counter = 0
while True:
self.publish('com.demo.tick', counter)
counter += 1
yield sleep(1)
from asyncio import sleep
from autobahn import wamp
from autobahn.asyncio.wamp import ApplicationSession
class ExamplePython3Component(ApplicationSession):
@wamp.register(u'com.demo.add')
def add(x, y)
return x + y
async def onJoin(self, details):
await self.register(self)
counter = 0
while True:
self.publish('com.demo.tick', counter)
counter += 1
await sleep(1)