Skip to content

WAMP Router in Python made for embedded situations

License

Notifications You must be signed in to change notification settings

JohnDoee/wampyre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WAMPyre

https://travis-ci.org/JohnDoee/wampyre.svg?branch=master

WAMPyre is a Python WAMP router with a bit of a pluggable architecture.

The goal is a basic router that allows for embedding into all-in-one applications. For every other situation, crossbar (or another implementation) is the correct choice.

It also includes a transport for Autobahn so you don't need to do that over TCP.

Who should use this

Probably only me, the only use-case is where you need a Python router and cannot use Crossbar, i.e. embeddable with more premissive license.

How to use

Use with Django Channels, add the following to routing.py:

from wampyre.transports.django import WAMPRouter

application = ProtocolTypeRouter({
    "websocket": URLRouter([
        path("router/", WAMPRouter),
    ]),
})

This way you can use authentication the same way you do with other Django Channels Websocket projects.

There is also a built-in transport for Autobahn that makes it possible to interact with the Router without creating an actual TCP connection.

from autobahn.twisted.wamp import ApplicationSession
from wampyre.transports.autowamp import ApplicationRunner
from twisted.internet.defer import inlineCallbacks

class Component(ApplicationSession):
    """
    An application component that publishes an event every second.
    """

    @inlineCallbacks
    def onJoin(self, details):
        print("session attached")
        def ping():
            return 'Pong!'
        yield self.register(ping, u'com.arguments.ping')

ApplicationRunner('crossbardemo', ).run(Component)

This can be put in any file, just make sure it's loaded when Django Channels is initiated.

License

MIT

About

WAMP Router in Python made for embedded situations

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages