-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: copy autobahn and fix package.json
- Loading branch information
Showing
91 changed files
with
11,291 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
MIT License | ||
Copyright (C) Crossbar.io Technologies GmbH and contributors. | ||
|
||
Copyright (c) 2021 errsole | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,217 @@ | ||
# autobahn | ||
# **Autobahn**|JS | ||
|
||
WAMP for Browsers and NodeJS. | ||
|
||
[![NPM](https://nodei.co/npm/autobahn.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/autobahn/) | ||
|
||
[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/crossbario/autobahn-js/) | ||
[![Build Status](https://travis-ci.org/crossbario/autobahn-js.svg?branch=master)](https://travis-ci.org/crossbario/autobahn-js) | ||
|
||
**npm quicklinks:** | ||
|
||
* [**autobahn**](https://www.npmjs.com/package/autobahn/) - Autobahn for NodeJS | ||
* [**autobahn-browser**](https://www.npmjs.com/package/autobahn-browser/) - Autobahn for browsers | ||
* [**autobahn-xbr**](https://www.npmjs.com/package/autobahn-xbr/) - Autobahn-[XBR](https://xbr.network/) for NodeJS | ||
* [**autobahn-xbr-browser**](https://www.npmjs.com/package/autobahn-xbr-browser/) - Autobahn-[XBR](https://xbr.network/) for browsers | ||
|
||
**XBR quicklinks:** | ||
|
||
* [XBR Network](https://xbr.network/) - The XBR Network homepage. | ||
* [XBR Protocol](https://github.com/crossbario/xbr-protocol) - The XBR Protocol source repository. | ||
* [XBR Docs](https://xbr.network/docs/protocol/index.html) - XBR Protocol and APIs Documentation. | ||
|
||
--- | ||
|
||
**Autobahn**|JS is a subproject of the [Autobahn project](http://autobahn.ws/) and provides an open-source implementation of the **[Web Application Messaging Protocol V2](http://wamp.ws/)** in JavaScript under the [MIT license](/LICENSE). | ||
|
||
WAMP provides asynchronous **Remote Procedure Calls** and **Publish & Subscribe** for applications in *one* protocol running over [WebSocket](http://tools.ietf.org/html/rfc6455) (and fallback transports for old browsers). | ||
|
||
**Autobahn**|JS runs on both **Web browsers** and **[Node.js](http://nodejs.org/)**. | ||
|
||
## What can I do with this stuff? | ||
|
||
**Autobahn|JS** makes **distributed, realtime Web applications easy**: it provides the infrastructure for both **distributing live updates** to all connected clients (using the PubSub messaging pattern) and for **calling remote procedures** in different backend components (using RPC). | ||
|
||
It is ideal for distributed, multi-client and server applications, such as multi-user database-drive business applications, real-time charts, sensor networks (IoT), instant messaging or MMOGs (massively multi-player online games). | ||
|
||
The protocol that **Autobahn|JS** uses, WAMP, enables application architectures with application code **distributed freely across processes and devices** according to functional aspects. All WAMP clients are equal in that they can publish events and subscribe to them, can offer a procedure for remote calling and call remote procedures. | ||
|
||
Since WAMP implementations exist for **multiple languages**, this extends beyond JavaScript clients: WAMP applications can be polyglot. Application components can be implemented in a language and run on a device which best fit the particular use case. Applications can span the range from embedded IoT sensors right to mobile clients or the browser - using the same protocol. | ||
|
||
## Show me some code | ||
|
||
The following example implements all four roles that **Autobahn**|JS offers | ||
|
||
* Publisher | ||
* Subscriber | ||
* Caller (calls a remote procedure) | ||
* Callee (offers a remote procedure) | ||
|
||
**The code runs unaltered in the browser or Node.js!** | ||
|
||
```javascript | ||
try { | ||
// for Node.js | ||
var autobahn = require('autobahn'); | ||
} catch (e) { | ||
// for browsers (where AutobahnJS is available globally) | ||
} | ||
|
||
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(); | ||
``` | ||
|
||
Features | ||
-------- | ||
|
||
* supports WAMP v2, works with any WAMP server | ||
* works both in the browser and Node.js | ||
* provides asynchronous RPC and PubSub messaging patterns | ||
* uses WebSocket or HTTP long-poll as transport | ||
* easy to use Promise-based API | ||
* pluggable promises/deferreds: use [when.js](https://github.com/cujojs/when) (built-in), [jQuery](http://api.jquery.com/category/deferred-object/) , [Dojo](http://dojotoolkit.org/reference-guide/1.7/dojo/Deferred.html), ECMA Script 6 or others | ||
* no dependencies | ||
* small size (244kB source, 111kB minified, 33kB compressed) | ||
* Open-Source (MIT License) | ||
|
||
|
||
## Get it | ||
|
||
### Browser Development | ||
|
||
The *latest* built release of AutobahnJS can be retrieved by cloning [this](https://github.com/crossbario/autobahn-js-browser) repository. You can then host the library wherever you need to. | ||
|
||
This also contains a complete history of previous releases and can be used with **[Bower](http://bower.io/)**. To install: | ||
|
||
bower install autobahn | ||
|
||
|
||
### NodeJS Development | ||
|
||
AutobahnJS is available via the Node package manager [here](https://www.npmjs.org/package/autobahn). To install: | ||
|
||
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. | ||
|
||
#### Usage on Ubuntu | ||
|
||
As mentioned above, Ubuntu 16.04 ships with Node 4.2, which only works with ws v1. To use that, do the following: | ||
|
||
```console | ||
sudo npm install -g ws@1 autobahn | ||
export NODE_PATH=/usr/local/lib/node_modules/ | ||
``` | ||
|
||
> This first install ws at version 1, and then installs Autobahn. When you install Autobahn without installing ws first, the latest ws version will be installed as a dependency of Autobahn, hence ws v2, and that won't work. | ||
To use a current Node with ws v2, do the following: | ||
|
||
```console | ||
cd ~ | ||
wget https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-x64.tar.xz | ||
tar xvf node-v6.10.1-linux-x64.tar.xz | ||
export PATH=${HOME}/node-v6.10.1-linux-x64/bin:${PATH} | ||
export NODE_PATH=${HOME}/node-v6.10.1-linux-x64/lib/node_modules | ||
``` | ||
|
||
This should give you: | ||
|
||
```console | ||
oberstet@office-corei7:~$ which node | ||
/home/oberstet/node-v6.10.1-linux-x64/bin/node | ||
oberstet@office-corei7:~$ which npm | ||
/home/oberstet/node-v6.10.1-linux-x64/bin/npm | ||
oberstet@office-corei7:~$ node -v | ||
v6.10.1 | ||
oberstet@office-corei7:~$ npm -v | ||
3.10.10 | ||
``` | ||
|
||
Now you can install Autobahn: | ||
|
||
```console | ||
npm install -g autobahn | ||
``` | ||
|
||
and check | ||
|
||
```console | ||
oberstet@office-corei7:~$ node -e "var autobahn = require('autobahn'); console.log(autobahn.version);" | ||
0.12.0 | ||
``` | ||
|
||
## More information | ||
|
||
For more information, take a look at the [project documentation](/doc/README.md). This provides: | ||
|
||
* [a quick 'Getting Started'](/doc/getting-started.md) | ||
* [a basic introduction to programming with Autobahn|JS](/doc/programming.md) | ||
* [a list of all examples in this repo](/doc/examples.md) | ||
* [a full API reference](/doc/reference.md) | ||
|
||
|
||
## Get in touch | ||
|
||
Get in touch on IRC `#autobahn` on `chat.freenode.net` or the [mailing list](http://groups.google.com/group/autobahnws). | ||
|
||
|
||
## Acknowledgements | ||
|
||
**Autobahn**|JS includes code from the following open-source projects | ||
|
||
* [when.js](https://github.com/cujojs/when) | ||
* [ws: a node.js websocket library](https://github.com/einaros/ws) | ||
* [CryptoJS](http://code.google.com/p/crypto-js/) | ||
|
||
Special thanks to the [Coders with an Unhealthy Javascript Obsession](http://cujojs.com/) for creating *when.js - A lightweight Promise and when() implementation, plus other async goodies.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import os | ||
import json | ||
import pkg_resources | ||
import subprocess | ||
from sys import platform | ||
|
||
taschenmesser = pkg_resources.resource_filename('taschenmesser', '..') | ||
#taschenmesser = "../../infrequent/taschenmesser" | ||
ENV=os.environ | ||
|
||
if 'JAVA_HOME' in ENV: | ||
print('Using from environment: JAVA_HOME={}'.format(ENV['JAVA_HOME'])) | ||
elif platform == "darwin": | ||
ENV['JAVA_HOME'] = subprocess.check_output("/usr/libexec/java_home").strip() | ||
print('Using OSX default: JAVA_HOME={}'.format(ENV['JAVA_HOME'])) | ||
elif platform == "linux" or platform == "linux2": | ||
ENV['JAVA_HOME'] = subprocess.check_output("echo 'System.out.println(java.lang.System.getProperty(\"java.home\"));' | jshell -", shell=True).strip() | ||
print('Using Linux default: JAVA_HOME={}'.format(ENV['JAVA_HOME'])) | ||
|
||
if 'JS_COMPILER' in ENV: | ||
print('Using from environment: JS_COMPILER={}'.format(ENV['JS_COMPILER'])) | ||
else: | ||
#ENV['JS_COMPILER'] = '/usr/local/lib/node_modules/google-closure-compiler-java/compiler.jar' | ||
ENV['JS_COMPILER'] = str(Dir('.').abspath) + '/node_modules/google-closure-compiler-java/compiler.jar' | ||
print('Using builtin: JS_COMPILER={}'.format(ENV['JS_COMPILER'])) | ||
|
||
env = Environment(tools = ['default', 'taschenmesser'], | ||
toolpath = [taschenmesser], | ||
ENV = ENV) | ||
|
||
# Get package version | ||
version = json.load(open('package.json'))['version'] | ||
print("Building AutobahnJS {}".format(version)) | ||
|
||
env['JS_DEFINES'] = { | ||
# 'AUTOBAHNJS_VERSION': "'%s'" % version | ||
} | ||
|
||
# Source for Autobahn package | ||
sourcedir = 'lib' | ||
sources = [os.path.join(sourcedir, d) for d in os.listdir(sourcedir)] | ||
|
||
# browserified | ||
ab = env.Command("build/autobahn.js", | ||
"lib/autobahn.js", | ||
"./node_modules/browserify/bin/cmd.js $SOURCE --ignore-missing --standalone autobahn -o $TARGET") | ||
Depends(ab, sources) | ||
|
||
if True: | ||
# minimized (with Google Closure) | ||
ab_min = env.JavaScript("build/autobahn.min.js", | ||
ab, | ||
#JS_COMPILATION_LEVEL = "ADVANCED_OPTIMIZATIONS") | ||
JS_COMPILATION_LEVEL = "SIMPLE_OPTIMIZATIONS", | ||
JS_OUTPUT_LANG = "ES5") | ||
|
||
# minimized & compressed | ||
ab_min_gz = env.GZip("build/autobahn.min.jgz", | ||
ab_min) | ||
|
||
# list of generated artifacts | ||
artifacts = [ab, | ||
ab_min, | ||
ab_min_gz] | ||
else: | ||
artifacts = [ab] | ||
|
||
# generate checksum files | ||
checksums = [] | ||
checksums.append(env.MD5("build/CHECKSUM.MD5", artifacts)) | ||
checksums.append(env.SHA1("build/CHECKSUM.SHA1", artifacts)) | ||
checksums.append(env.SHA256("build/CHECKSUM.SHA256", artifacts)) | ||
|
||
# fixed static files to be included | ||
statics = [] | ||
for f in ["LICENSE"]: | ||
statics.append(Command("build/{}".format(f), [], Copy("$TARGET", f))) | ||
|
||
# The default target consists of all artifacts that | ||
# would get published | ||
uploads = artifacts + checksums + statics | ||
Default(uploads) | ||
#Default(ab) | ||
|
||
# Upload to Amazon S3 | ||
env['S3_BUCKET'] = 'autobahn' | ||
env['S3_OBJECT_ACL'] = 'public-read' | ||
|
||
published = [] | ||
|
||
for s in ['latest', version]: | ||
e = env.Clone(S3_BUCKET_PREFIX = 'autobahnjs/{}/'.format(s)) # note the trailing slash! | ||
published.append(AlwaysBuild(e.S3("build/.S3UploadDone_{}".format(s), uploads))) | ||
|
||
|
||
# The uploaded stuff is always considered stale | ||
Depends(published, uploads) | ||
|
||
Alias("publish", published) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// AutobahnJS - http://autobahn.ws, http://wamp.ws | ||
// | ||
// A JavaScript library for WAMP ("The Web Application Messaging Protocol"). | ||
// | ||
// Copyright (c) Crossbar.io Technologies GmbH and contributors | ||
// | ||
// Licensed under the MIT License. | ||
// http://www.opensource.org/licenses/mit-license.php | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
module.exports = require('./lib/autobahn.js'); |
Oops, something went wrong.