GithubHelp home page GithubHelp logo

danielfaust / autobahnjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crossbario/autobahn-js

1.0 2.0 0.0 147 KB

WAMP for JavaScript

Home Page: http://autobahn.ws/developers/autobahnjs

License: MIT License

autobahnjs's Introduction

AutobahnJS

  • Asynchronous RPC/PubSub over WebSocket
  • WAMP compatible implementation (see http://wamp.ws)
  • no dependencies
  • tiny size (47kB, 13kB minified, 5kB compressed)
  • MIT License

What is that?

WebSockets http://tools.ietf.org/html/rfc6455 is already built into modern browsers and provides full-duplex, low-latency communication.

However, as such, it is quite low-level. Web apps often have a need for higher level messaging patterns:

  • Publish & Subscribe
  • Remote Procedure Calls

This is where WAMP enters. WAMP (The WebSocket Application Messaging Protocol) runs on top of raw WebSocket and provides PubSub and RPC.

Technically, WAMP is a proper WebSocket subprotocol that uses JSON as message serialization format. WAMP was designed to be easy to use and simple to implement.

AutobahnJS implements WAMP in JavaScript to be used in browser based applications.

Read more about WAMP and other WAMP compatible implementations on http://wamp.ws

Show me the code!

This is how you do publish & subscribe with AutobahnJS.

Include AutobahnJS

  <script src="http://autobahn.ws/public/autobahn.min.js"></script>

.. connect and subscribe to receive events on a topic

  var sess;

  window.onload = function() {
     sess = new ab.Session("ws://localhost:9000", function() {

        sess.subscribe("http://example.com/event#event1", onEvent1);
     });
  };

  function onEvent1(topic, event) {
     alert("got event: " + event);
  }

.. and publish an event to a topic

  function publishEvent1() {

     sess.publish("http://example.com/event#event1", {a: 23, b: "foobar"});
  };

  ...

  <button onclick="publishEvent1();">Publish!</button>

You can find a complete app template including proper error handling here

http://localhost:8080/developers/autobahnjs/reference#apptemplate

More Information

For more information, including tutorials and reference, please visit:

http://autobahn.ws/developers/autobahnjs

Contact

Get in touch on IRC #autobahn on chat.freenode.net or join the mailing list on http://groups.google.com/group/autobahnws.

autobahnjs's People

Contributors

ryanhope avatar

Stargazers

 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.