Difference between revisions of "WAMP"

From air
Jump to navigation Jump to search
Line 9: Line 9:
   
 
==[[Node.js]]==
 
==[[Node.js]]==
http://autobahn.ws/js/gettingstarted.html
+
* http://crossbar.io/
  +
http://autobahn.ws/js/programming.html
 
  +
* http://autobahn.ws/js/gettingstarted.html
 
* http://autobahn.ws/js/programming.html
   
 
<pre>
 
<pre>

Revision as of 23:12, 16 November 2014

WAMP (Web Application Messaging Protocol) is an open WebSocket subprotocol that provides two application messaging patterns in one unified protocol: Remote Procedure Calls + Publish-Subscribe

Extra

Node.js

npm install autobahn



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();

Node-RED

TODO