Git Product home page Git Product logo

autobahn-js's Introduction

Autobahn|JS

Autobahn|JS is a subproject of the Autobahn project and provides an open-source implementation of the Web Application Messaging Protocol V2 in JavaScript

It is licensed under the MIT licensed.

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

Autobahn|JS runs on both Web browsers and Node.js.

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 polyglott. Application components can be implemented in a language and run on a device which best fit the particular use case.

Show me some code

The following example implements all four roles that Autobahn|JS offers

  • Publisher
  • Subscriber
  • Caller (calls a remote procedure)
  • Callee (offers a remote procedure)

The code runs unaltered in the browser or Node.js!

var autobahn = require('autobahn');

var connection = new autobahn.Connection({url: 'ws://127.0.0.1:9000/', realm: 'realm1'});

connection.onopen = function (session) {

   // 1) subscribe to a topic
   function onevent(args) {
      console.log("Event:", args[0]);
   }
   session.subscribe('com.myapp.hello', onevent);

   // 2) publish an event
   session.publish('com.myapp.hello', ['Hello, world!']);

   // 3) register a procedure for remoting
   function add2(args) {
      return args[0] + args[1];
   }
   session.register('com.myapp.add2', add2);

   // 4) call a remote procedure
   session.call('com.myapp.add2', [2, 3]).then(
      function (res) {
         console.log("Result:", res);
      }
   );
};

connection.open();

Get it

Browser Development

The latest release of AutobahnJS can be downloaded from here:

Previous releases are available under respective links containing the version number:

A complete history of AutobahnJS releases is also available from the built repository.

The latter can also be used with Bower:

bower install autobahn

NodeJS Development

AutobahnJS is available via the Node package manager here. To install:

npm install autobahn

More information

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

Get in touch

Get in touch on IRC #autobahn on chat.freenode.net or the mailing list.

Acknowledgements

Autobahn|JS includes code from the following open-source projects

Special thanks to the Coders with an Unhealthy Javascript Obsession for creating when.js - A lightweight Promise and when() implementation, plus other async goodies.

autobahn-js's People

Contributors

simlgce avatar svvac avatar adamchainz avatar ryanhope avatar arnoschn avatar rafzi avatar andremiras avatar hugohenrique avatar igorw avatar taion avatar joekepley avatar jmarine avatar djiit avatar markope avatar robertkraig avatar jourdain avatar dynalon avatar tjanson avatar jordancrook avatar

Watchers

Sangkyun Yoon 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.