Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

fix default ports in examples #17

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f6fe6ff
fix default ports in examples
kalmyk Jan 24, 2016
eeaf6f2
realm + unit test
kalmyk Mar 8, 2016
a5ffb7d
CALL and PUBLISH tests
kalmyk Mar 8, 2016
be81c11
router callrpc with args and kwargs
kalmyk Mar 9, 2016
b6818d7
optimize publish arguments
kalmyk Mar 9, 2016
bc9e679
move sessionId generator to create session
kalmyk Mar 10, 2016
787df5d
refactoring step 1
kalmyk Mar 19, 2016
370d606
test unsubscribe and unregister
kalmyk Mar 19, 2016
08df015
unregister test
kalmyk Mar 19, 2016
7be5fd0
unregister error test
kalmyk Mar 19, 2016
d980085
Merge branch 'master' into general_refactoring
kalmyk Mar 19, 2016
aa574e8
merge fix
kalmyk Mar 19, 2016
f6c0c94
fix demo
kalmyk Mar 19, 2016
8d9739f
test error in remote call
kalmyk Mar 19, 2016
61d23c0
Merge branch 'master' into general_refactoring
kalmyk Mar 19, 2016
7230dcd
post refactoring cleaning
kalmyk Mar 19, 2016
7ab8653
welcome back event emiter
kalmyk Mar 21, 2016
04d6d4c
ticket auth added
kalmyk Apr 3, 2016
364892d
read me change
kalmyk Apr 3, 2016
347e41a
session optimization
kalmyk Apr 11, 2016
aef3ee8
tests cleaning
kalmyk Apr 16, 2016
47284c8
dedicated auth object added
kalmyk Apr 16, 2016
87c4093
small optimization
kalmyk Apr 18, 2016
d98c9c3
jshint parsed
kalmyk May 8, 2016
a858d38
callback to get realm
kalmyk May 30, 2016
f74c4fd
alternative logging
kalmyk Jun 9, 2016
39eaa3a
test log
kalmyk Jun 21, 2016
cafdf0c
requirements
kalmyk Apr 24, 2017
43d4ab9
event emiter instead of log
kalmyk Apr 25, 2017
97c61b4
Merge branch 'alt_log'
kalmyk Apr 25, 2017
44d20cb
add statsd integration
kalmyk Apr 27, 2017
7a92a9a
add statsd integration
kalmyk Apr 27, 2017
5359095
kw to rpc result
kalmyk Apr 29, 2017
458dcc6
exclude_me option of publish
kalmyk May 8, 2017
5dcf0ed
Concrete topic published to
kalmyk May 18, 2017
3aa61ba
Progressive Calls
kalmyk May 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# wamp.rt: A WAMP V2 nodejs router
##Copyright Orange 2014, All Rights Reserved
# FOX.WAMP is a WAMP v2 message router implementation

wamp.rt is a WebSocket Application Messaging Protocol [WAMP](http://wamp.ws/) V2 router implementation based on nodejs.

The router is compliant with the WAMP V2 [Basic Profile](https://github.com/tavendo/WAMP/blob/master/spec/basic.md).

wamp.rt implements both [Dealer](https://github.com/tavendo/WAMP/blob/master/spec/basic.md#peers-and-roles) and [Broker](https://github.com/tavendo/WAMP/blob/master/spec/basic.md#peers-and-roles) roles.
The message router is compliant with the [WAMP V2 Basic Profile](http://wamp-proto.org/).

## Build Instructions

Install using npm. Depending on what you want to do, your mileage may vary.

## Credits

wamp.rt has been inspired by the following Open Source projects:
fox.wamp has been inspired by the following Open Source projects:

- [wamp.rt](https://github.com/Orange-OpenSource/wamp.rt)
- [wamp.io](https://github.com/nicokaiser/wamp.io)


## Changes:
2017-05-17:
- Concrete topic published to
- Progressive Calls (receive_progress & progress)

2017-05-07:
- exclude_me option of publish

2017-04-26:
- integration with [StatsD](https://github.com/etsy/statsd)

- [wamp.io](https://github.com/nicokaiser/wamp.io)
2016-04-03:
- ticket auth support added

2016-03-09:
- internal api moved to realm
- callrpc method has args & kwargs arguments
- publish method does not require message id
114 changes: 114 additions & 0 deletions democli/backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
AUTOBAHN_DEBUG = true;
var autobahn = require('autobahn');
var program = require('commander');

program
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connectUrl = 'ws://' + program.ip + ':' + program.port;
console.log('connectUrl:', connectUrl);

var connection = new autobahn.Connection({
url: connectUrl,
realm: 'realm1'}
);

connection.onopen = function (session) {

var reg = null;
var reg2 = null;

function utcprogress(args, kwargs, options) {
console.log("Someone is calling utc function", args, kwargs, options);
if (options.progress) {
setTimeout(function () {
var now = new Date();
options.progress(now.toISOString());
}, 100);
setTimeout(function () {
var now = new Date();
options.progress(now.toISOString());
}, 200);
return new Promise((resolve, reject) => {
setTimeout(function () {
var now = new Date();
resolve(now.toISOString());
}, 300);
});
}
else {
var now = new Date();
return now.toISOString();
}
}

session.register('com.timeservice.now', utcprogress).then(
function (registration) {
console.log("Procedure registered:", registration.id);
reg = registration;
},
function (error) {
console.log("Registration failed:", error);
}
);

function echo(args,kwargs) {
console.log("args",args,"kwargs",kwargs);
return new autobahn.Result(args, kwargs);
}

session.register('com.echoservice.echo', echo).then(
function (registration) {
console.log("Procedure echo registered:", registration.id);
reg2 = registration;
},
function (error) {
console.log("Registration failed:", error);
}
);

// Define an event handler
function onEvent(publishArgs, kwargs, opts) {
console.log('Event', opts.topic, 'received args', publishArgs, 'kwargs ',kwargs);
}

// Subscribe to a topic
session.subscribe('com.myapp.topic1', onEvent).then(
function(subscription) {
console.log("subscription successfull", subscription);
},
function(error) {
console.log("subscription failed", error);
}
);

session.subscribe('wamp.session.on_join', onEvent).then(
function(subscription) {
console.log("subscription successfull", subscription);
},
function(error) {
console.log("subscription failed", error);
}
);

session.subscribe('wamp.session.on_leave', onEvent).then(
function(subscription) {
console.log("subscription successfull", subscription);
},
function(error) {
console.log("subscription failed", error);
}
);

setTimeout(function() {
console.log("Unregistration");
session.unregister(reg);
session.unregister(reg2);
},
20000
);
};

connection.open();
61 changes: 41 additions & 20 deletions test/frontend.js → democli/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,52 @@ var autobahn = require('autobahn');
var program = require('commander');

program
.option('-p, --port <port>', 'Server IP port', parseInt,9000)
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connection = new autobahn.Connection({
url: 'ws://' + program.ip + ':' + program.port,
realm: 'realm1'}
);
var connectUrl = 'ws://' + program.ip + ':' + program.port + '/ws';
console.log('connectUrl:', connectUrl);

var user = "joe";
var key = "joe-secret";

// this callback is fired during authentication
function onchallenge (session, method, extra) {
if (method === "ticket") {
return key;
} else {
throw "don't know how to authenticate using '" + method + "'";
}
}

var session = null;
var connection = new autobahn.Connection({
url: connectUrl,
realm: 'realm1',
// authmethods: ["ticket", "wampcra"],
authid: user,
onchallenge: onchallenge
});

connection.onopen = function (new_session) {
connection.onopen = function (session, details) {

session = new_session;
session.log("Session open.");

var starttime = Date.now();
session.call('com.timeservice.now').then(
var c1 = session.call('com.timeservice.now', [], {}, {receive_progress:true}).then(
function (now) {
// this method returns a plain value
session.log("Call com.timeservice.now completed in " +
(Date.now() - starttime) +
" ms: result =", now);
},
function (error) {
console.log("Call failed:", error);
});
console.log("Call failed:", error);
},
function (progress) {
console.log("Call progress:", progress);
}
);

session.call('com.echoservice.echo').then(
function (res) {
Expand Down Expand Up @@ -90,12 +109,11 @@ connection.onopen = function (new_session) {
}
);

session.call('wamp.rt.foo',["test"]).then(
session.call('test.foo', ["test"], {foo:'bar'}).then(
function (res) {
session.log("Call wamp.rt.foo completed in " +
session.log("Call test.foo completed in " +
(Date.now() - starttime) +
" ms: result =", res);

},
function (error) {
console.log("Call failed:", error);
Expand All @@ -111,20 +129,23 @@ connection.onopen = function (new_session) {
session.publish('com.myapp.topic1', ["Arg1", "Arg2" ], { "kwarg1": "kwarg1", "kwarg2": "kwarg2"}, { acknowledge : false });


session.publish('com.myapp.topic1', [ "Arg_1", "Arg_2" ], {}, { acknowledge : true }).then(
var p1 = session.publish('com.myapp.topic1', [ "Arg_1", "Arg_2" ], {}, { acknowledge : true }).then(
function(publication) {
console.log("published, publication ID is ", publication);
connection.close();
},
function(error) { console.log("publication error", error);
connection.close();
function(error) {
console.log("publication error", error);
return Promise.resolve(true);
}
);

Promise.all([c1,p1]).then(function () {
connection.close();
});
};

connection.onclose = function (reason, details) {
console.log("connection 1", reason, details);
console.log("close connection:", reason, details);
};

connection.open();

7 changes: 5 additions & 2 deletions test/pubsub/publisher.js → democli/pubsub/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ var program = require('commander');
var when = require('when');

program
.option('-p, --port <port>', 'Server IP port', parseInt,9000)
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connectUrl = 'ws://' + program.ip + ':' + program.port;
console.log('connectUrl:', connectUrl);

var connection = new autobahn.Connection({
url: 'ws://' + program.ip + ':' + program.port,
url: connectUrl,
realm: 'realm1'}
);

Expand Down
7 changes: 5 additions & 2 deletions test/pubsub/subscriber.js → democli/pubsub/subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ var autobahn = require('autobahn');
var program = require('commander');

program
.option('-p, --port <port>', 'Server IP port', parseInt,9000)
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connectUrl = 'ws://' + program.ip + ':' + program.port;
console.log('connectUrl:', connectUrl);

var connection = new autobahn.Connection({
url: 'ws://' + program.ip + ':' + program.port,
url: connectUrl,
realm: 'realm1'}
);

Expand Down
9 changes: 6 additions & 3 deletions test/rpc/client.js → democli/rpc/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ var program = require('commander');
var when = require('when');

program
.option('-p, --port <port>', 'Server IP port', parseInt,9000)
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connectUrl = 'ws://' + program.ip + ':' + program.port;
console.log('connectUrl:', connectUrl);

var connection = new autobahn.Connection({
url: 'ws://' + program.ip + ':' + program.port,
realm: 'realm1'}
url: connectUrl,
realm: 'realm1'}
);

connection.onopen = function (session) {
Expand Down
9 changes: 6 additions & 3 deletions test/rpc/server.js → democli/rpc/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ var autobahn = require('autobahn');
var program = require('commander');

program
.option('-p, --port <port>', 'Server IP port', parseInt,9000)
.option('-p, --port <port>', 'Server IP port', 9000)
.option('-i, --ip <ip>', 'Server IP address','127.0.0.1')
.parse(process.argv);

var connectUrl = 'ws://' + program.ip + ':' + program.port;
console.log('connectUrl:', connectUrl);

var connection = new autobahn.Connection({
url: 'ws://' + program.ip + ':' + program.port,
realm: 'realm1'}
url: connectUrl,
realm: 'realm1'}
);

connection.onopen = function (session) {
Expand Down
Loading