WAMP: Difference between revisions
Jump to navigation
Jump to search
(→Extra) |
|||
| Line 43: | Line 43: | ||
connection.open(); |
connection.open(); |
||
</pre> |
</pre> |
||
==[[Node-RED]]== |
|||
TODO |
|||
Revision as of 21:07, 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
- http://wamp.ws/spec/
- https://github.com/tavendo/WAMP/blob/master/spec/basic.md
- https://github.com/tavendo/WAMP/blob/master/spec/advanced.md
Extra
- WAMP with Arduino Yun http://tavendo.com/blog/post/arduino-yun-with-autobahn/
Node.js
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