GithubHelp home page GithubHelp logo

tempbottle / autobahnpython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crossbario/autobahn-python

0.0 2.0 0.0 9.92 MB

WebSocket & WAMP for Python on Twisted and asyncio

Home Page: http://autobahn.ws/python

License: MIT License

Makefile 0.32% Python 86.77% HTML 5.75% Arduino 0.18% JavaScript 6.98% Shell 0.01%

autobahnpython's Introduction

Autobahn|Python

Build Status   Version   Downloads

Autobahn|Python is a subproject of Autobahn and provides open-source implementations of

in Python running on Twisted and asyncio.

You can use Autobahn|Python to create clients and servers in Python speaking just plain WebSocket or WAMP.

WebSocket allows bidirectional real-time messaging on the Web and WAMP adds asynchronous Remote Procedure Calls and Publish & Subscribe on top of WebSocket.

WAMP provides asynchronous Remote Procedure Calls and Publish & Subscribe for applications in one protocol running over WebSocket (and fallback transports for old browsers).

It is ideal for distributed, multi-client and server applications, such as multi-user database-drive business applications, sensor networks (IoT), instant messaging or MMOGs (massively multi-player online games) .

WAMP enables application architectures with application code distributed freely across processes and devices according to functional aspects. Since WAMP implementations exist for multiple languages, WAMP applications can be polyglot. Application components can be implemented in a language and run on a device which best fit the particular use case.

Note that WAMP is a routed protocol, so you need to run something that plays the Broker and Dealer roles from the WAMP Specification. We provide Crossbar.io but there are other options as well.

Show me some code

A simple WebSocket echo server:

from autobahn.twisted.websocket import WebSocketServerProtocol
# or: from autobahn.asyncio.websocket import WebSocketServerProtocol

class MyServerProtocol(WebSocketServerProtocol):

   def onConnect(self, request):
      print("Client connecting: {}".format(request.peer))

   def onOpen(self):
      print("WebSocket connection open.")

   def onMessage(self, payload, isBinary):
      if isBinary:
         print("Binary message received: {} bytes".format(len(payload)))
      else:
         print("Text message received: {}".format(payload.decode('utf8')))

      ## echo back message verbatim
      self.sendMessage(payload, isBinary)

   def onClose(self, wasClean, code, reason):
      print("WebSocket connection closed: {}".format(reason))

... and a sample WAMP application component:

from autobahn.twisted.wamp import ApplicationSession
# or: from autobahn.asyncio.wamp import ApplicationSession

class MyComponent(ApplicationSession):

   def onConnect(self):
      self.join("realm1")


   @inlineCallbacks
   def onJoin(self, details):

      # 1) subscribe to a topic
      def onevent(msg):
         print("Got event: {}".format(msg))

      yield self.subscribe(onevent, 'com.myapp.hello')

      # 2) publish an event
      self.publish('com.myapp.hello', 'Hello, world!')

      # 3) register a procedure for remoting
      def add2(x, y):
         return x + y

      self.register(add2, 'com.myapp.add2');

      # 4) call a remote procedure
      res = yield self.call('com.myapp.add2', 2, 3)
      print("Got result: {}".format(res))

Features

  • framework for WebSocket / WAMP clients and servers
  • compatible with Python 2.6, 2.7, 3.3 and 3.4
  • runs on CPython, PyPy and Jython
  • runs under Twisted and asyncio
  • implements WebSocket RFC6455, Draft Hybi-10+, Hixie-76
  • implements WebSocket compression
  • implements WAMP, the Web Application Messaging Protocol
  • high-performance, fully asynchronous implementation
  • best-in-class standards conformance (100% strict passes with Autobahn Testsuite)
  • message-, frame- and streaming-APIs for WebSocket
  • supports TLS (secure WebSocket) and proxies
  • Open-source (MIT license)

More Information

For more information, take a look at the project documentation. This provides:

WAMP Version 1: Looking for WAMP version 1? The last version of AutobahnPython supporting WAMP1 was 0.8.15. WAMP version 1 is fully deprecated now and no further development happens on AutobahnPython.

Get in touch

Get in touch on IRC #autobahn on chat.freenode.net, follow us on Twitter or join the mailing list.

autobahnpython's People

Contributors

abrandl avatar ansman avatar cfillion avatar claws avatar dhananjaysathe avatar ewollesen avatar flyser avatar frewsxcv avatar girishramnani avatar gourneau avatar halflings avatar hawkowl avatar herm avatar hooksie avatar jkasky avatar jsoref avatar kampka avatar klemmster avatar luhn avatar meejah avatar mriehl avatar msiedlarek avatar mtiller avatar remyroy avatar rogererens avatar rusydi avatar sametmax avatar terrycojones avatar vstinner avatar zaphoyd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.