Skip to content

Commit

Permalink
Merge pull request crossbario#273 from oberstet/master
Browse files Browse the repository at this point in the history
rel_0.12.0
  • Loading branch information
oberstet authored Mar 27, 2017
2 parents 9cf943b + 5df2aae commit 79b093b
Show file tree
Hide file tree
Showing 32 changed files with 770 additions and 108 deletions.
121 changes: 121 additions & 0 deletions .crossbar/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"version": 2,
"workers": [
{
"type": "router",
"realms": [
{
"name": "crossbardemo",
"roles": [
{
"name": "anonymous",
"permissions": [
{
"uri": "",
"match": "prefix",
"allow": {
"call": true,
"register": true,
"publish": true,
"subscribe": true
},
"disclose": {
"caller": false,
"publisher": false
},
"cache": true
}
]
},
{
"name": "authenticated",
"permissions": [
{
"uri": "",
"match": "prefix",
"allow": {
"call": true,
"register": true,
"publish": true,
"subscribe": true
},
"disclose": {
"caller": false,
"publisher": false
},
"cache": true
}
]
}
]
}
],
"transports": [
{
"type": "universal",
"endpoint": {
"type": "tcp",
"port": 8080
},
"rawsocket": {
"serializers": [
"cbor", "msgpack", "ubjson", "json"
]
},
"websocket": {
"ws": {
"type": "websocket",
"serializers": [
"cbor", "msgpack", "ubjson", "json"
],
"options": {
"compression": {
"deflate": {
"request_no_context_takeover": false,
"request_max_window_bits": 13,
"no_context_takeover": false,
"max_window_bits": 13,
"memory_level": 5
}
}
}
},
"auth_ws": {
"type": "websocket",
"auth": {
"wampcra": {
"type": "static",
"users": {
"username": {
"secret": "p4ssw0rd",
"role": "authenticated"
}
}
},
"anonymous": {
"type": "static",
"role": "anonymous"
}
}
}
},
"web": {
"paths": {
"/": {
"type": "static",
"directory": ".",
"options": {
"enable_directory_listing": true,
"mime_types": {
".md": "text/plain",
".py": "text/plain"
}
}
}
}
}
}
]
}
]
}
7 changes: 7 additions & 0 deletions .crossbar/key.priv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Crossbar.io node private key - KEEP THIS SAFE!

creator: oberstet@thinkpad-t430s
created-at: 2017-03-26T23:29:47.358Z
machine-id: 7a3357418649414dbd536c31c6bd0ee8
public-key-ed25519: 9e837b9c3b8a14ad5bbeb6b3671403f31d2010e776a36e1833356ea4be0b30b3
private-key-ed25519: b12d4c6804da2884524addf1671d5e0d00ed0c2de624924c6b19331c4c4c9cbe
6 changes: 6 additions & 0 deletions .crossbar/key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Crossbar.io node public key

creator: oberstet@thinkpad-t430s
created-at: 2017-03-26T23:29:47.358Z
machine-id: 7a3357418649414dbd536c31c6bd0ee8
public-key-ed25519: 9e837b9c3b8a14ad5bbeb6b3671403f31d2010e776a36e1833356ea4be0b30b3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node-v*-linux-x64/
.sconsign.dblite
*.sublime-workspace
build
Expand Down
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ default:

clean:
rm -rf build
rm -rf ./node_modules
rm -f .sconsign.dblite
#rm -rf ./node_modules
#rm -f .sconsign.dblite

requirements:
pip install scons boto taschenmesser
pip install -U scons boto taschenmesser
sudo apt install -y npm nodejs-legacy default-jre
node -v
sudo npm install -g google-closure-compiler nodeunit

browser_deps:
npm install
npm update

build: build_browser build_npm

Expand All @@ -27,20 +34,26 @@ build_npm:

publish: publish_browser publish_npm

publish_browser:
publish_browser: build_browser
scons publish

copy_browser: build_browser
git -C ../autobahn-js-built pull
cp ./build/* ../autobahn-js-built
@echo "Now commit and push autobahn-js-built!"
cp ./build/* ../crossbar/crossbar/templates/default/web/js/
@echo "Now commit and push these repos: autobahn-js-built, crossbar"

publish_npm:
npm publish

crossbar:
crossbar start

test:
npm test

test_connect:
nodeunit test/test_connect.js

test_msgpack_serialization:
nodeunit test/test_msgpack_serialization.js
test_serialization_cbor:
nodeunit test/test_serialization_cbor.js
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ AutobahnJS is available via the Node package manager [here](https://www.npmjs.or

npm install autobahn

#### NodeJS and ws version

AutobahnJS works with both v1 and v2 of the ws library, and you should use the ws version depending on the NodeJS version you use.

If you run NodeJS v4.5.0 or later, you can use the ws library v2:

```console
npm install ws@2`
```

If you run an earlier version of NodeJS, use must use the ws library v1:

```console
npm install ws@1`
```

**Details**

AutobahnJS currently strives for support of NodeJS v4.2.6 or later. The reason is that this is the version that currently ships with Ubuntu 16.04 LTS.

On NodeJS, we need the [ws library](https://github.com/websockets/ws/) for WebSocket support, as different from browsers, NodeJS does not come with a native implementation.

However, the ws library v2 or later is incompatible with NodeJS earlier than v4.5.0. See [here](http://stackoverflow.com/a/42331959/884770) and [here](https://github.com/websockets/ws/issues/989).

Rather than dropping support for NodeJS v4 (and hence for the system NodeJS version of Ubuntu), we use ws v1 as a dependency in `package.json`, but allow any version of ws to be used.

## More information

Expand Down
8 changes: 6 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import pkg_resources

taschenmesser = pkg_resources.resource_filename('taschenmesser', '..')
#taschenmesser = "../../infrequent/taschenmesser"
ENV=os.environ

ENV['JS_COMPILER'] = '/usr/local/lib/node_modules/google-closure-compiler/compiler.jar'

env = Environment(tools = ['default', 'taschenmesser'],
toolpath = [taschenmesser],
ENV = os.environ)
ENV = ENV)

# Get package version
version = json.load(open('package.json'))['version']
Expand All @@ -23,7 +27,7 @@ sources = [os.path.join(sourcedir, d) for d in os.listdir(sourcedir)]
# browserified
ab = env.Command("build/autobahn.js",
"lib/autobahn.js",
"browserify $SOURCE --standalone autobahn -o $TARGET")
"/usr/local/lib/node_modules/browserify/bin/cmd.js $SOURCE --ignore-missing --standalone autobahn -o $TARGET")
Depends(ab, sources)

# minimized (with Google Closure)
Expand Down
2 changes: 2 additions & 0 deletions lib/autobahn.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var when = require('when');
//var fn = require("when/function");

var msgpack = require('msgpack-lite');
var cbor = require('cbor');

if ('AUTOBAHN_DEBUG' in global && AUTOBAHN_DEBUG) {
// https://github.com/cujojs/when/blob/master/docs/api.md#whenmonitor
Expand Down Expand Up @@ -61,6 +62,7 @@ exports.auth_cra = cra;

exports.when = when;
exports.msgpack = msgpack;
exports.cbor = cbor;

exports.util = util;
exports.log = log;
10 changes: 7 additions & 3 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ Connection.prototype._create_transport = function () {
}
} catch (e) {
// ignore
log.debug("could not create WAMP transport '" + transport_factory.type + "': " + e);
log.warn("could not create WAMP transport '" + transport_factory.type + "': " + e);
}
}

// could not create any WAMP transport
log.warn('could not create any WAMP transport');
return null;
};

Expand Down Expand Up @@ -276,7 +276,11 @@ Connection.prototype.open = function () {
function retry () {

// create a WAMP transport
self._transport = self._create_transport();
try {
self._transport = self._create_transport();
} catch (e) {
console.log(e);
}

if (!self._transport) {
// failed to create a WAMP transport
Expand Down
3 changes: 3 additions & 0 deletions lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ if ('AUTOBAHN_DEBUG' in global && AUTOBAHN_DEBUG && 'console' in global) {
}
}

var warn = console.warn;

exports.debug = debug;
exports.warn = warn;
Loading

0 comments on commit 79b093b

Please sign in to comment.