├── .gitignore
├── README
├── daemon
├── MANIFEST.in
├── orbited2
│ ├── __init__.py
│ ├── admin
│ │ └── __init__.py
│ ├── config.py
│ ├── js_src
│ │ ├── Makefile
│ │ ├── Orbited2.js
│ │ ├── Orbited2.pkg
│ │ ├── README
│ │ ├── jsio-3.2
│ │ │ ├── base.js
│ │ │ ├── index.js
│ │ │ ├── jsio.js
│ │ │ ├── lib
│ │ │ │ ├── Enum.js
│ │ │ │ ├── Hash.js
│ │ │ │ └── PubSub.js
│ │ │ ├── logging.js
│ │ │ ├── net.js
│ │ │ ├── net
│ │ │ │ ├── buffer.js
│ │ │ │ ├── csp
│ │ │ │ │ ├── client.js
│ │ │ │ │ └── transports.js
│ │ │ │ ├── env.js
│ │ │ │ ├── env
│ │ │ │ │ ├── browser
│ │ │ │ │ │ ├── csp.js
│ │ │ │ │ │ ├── networkConsole.html
│ │ │ │ │ │ ├── postmessage.js
│ │ │ │ │ │ └── websocket.js
│ │ │ │ │ └── node
│ │ │ │ │ │ ├── csp.js
│ │ │ │ │ │ ├── csp
│ │ │ │ │ │ ├── proxy.js
│ │ │ │ │ │ ├── server.js
│ │ │ │ │ │ └── util.js
│ │ │ │ │ │ └── tcp.js
│ │ │ │ ├── errors.js
│ │ │ │ ├── interfaces.js
│ │ │ │ ├── later.js
│ │ │ │ └── protocols
│ │ │ │ │ ├── buffered.js
│ │ │ │ │ ├── delimited.js
│ │ │ │ │ ├── echo.js
│ │ │ │ │ ├── mspp.js
│ │ │ │ │ ├── rtjp.js
│ │ │ │ │ └── stomp.js
│ │ │ ├── std
│ │ │ │ ├── JSON.js
│ │ │ │ ├── base64.js
│ │ │ │ ├── js.js
│ │ │ │ ├── uri.js
│ │ │ │ ├── utf8.js
│ │ │ │ └── uuid.js
│ │ │ └── util
│ │ │ │ ├── browser.js
│ │ │ │ ├── browserdetect.js
│ │ │ │ ├── sizzle.js
│ │ │ │ ├── sprintf.js
│ │ │ │ └── underscore.js
│ │ └── jsio-3.3alpha
│ │ │ ├── base.js
│ │ │ ├── index.js
│ │ │ ├── jsio.js
│ │ │ ├── lib
│ │ │ ├── Callback.js
│ │ │ ├── Enum.js
│ │ │ ├── Hash.js
│ │ │ ├── Iterator.js
│ │ │ ├── LogClass.js
│ │ │ ├── PubSub.js
│ │ │ └── Sortable.js
│ │ │ ├── logging.js
│ │ │ ├── math
│ │ │ ├── arrays.js
│ │ │ └── util.js
│ │ │ ├── math2D
│ │ │ ├── Circle.js
│ │ │ ├── Line.js
│ │ │ ├── Point.js
│ │ │ ├── Rect.js
│ │ │ ├── angle.js
│ │ │ ├── intersect.js
│ │ │ └── morphology.js
│ │ │ ├── net.js
│ │ │ ├── net
│ │ │ ├── buffer.js
│ │ │ ├── csp
│ │ │ │ ├── client.js
│ │ │ │ └── transports.js
│ │ │ ├── env.js
│ │ │ ├── env
│ │ │ │ ├── browser
│ │ │ │ │ ├── csp.js
│ │ │ │ │ ├── iframe.js
│ │ │ │ │ ├── networkConsole.html
│ │ │ │ │ ├── postmessage.js
│ │ │ │ │ └── websocket.js
│ │ │ │ └── node
│ │ │ │ │ ├── csp.js
│ │ │ │ │ ├── csp
│ │ │ │ │ ├── proxy.js
│ │ │ │ │ ├── server.js
│ │ │ │ │ └── util.js
│ │ │ │ │ ├── stdio.js
│ │ │ │ │ └── tcp.js
│ │ │ ├── errors.js
│ │ │ ├── interfaces.js
│ │ │ ├── later.js
│ │ │ └── protocols
│ │ │ │ ├── buffered.js
│ │ │ │ ├── delimited.js
│ │ │ │ ├── echo.js
│ │ │ │ ├── mspp.js
│ │ │ │ ├── rtjp.js
│ │ │ │ └── stomp.js
│ │ │ ├── preprocessors
│ │ │ ├── compiler.js
│ │ │ └── import.js
│ │ │ ├── std
│ │ │ ├── JSON.js
│ │ │ ├── base64.js
│ │ │ ├── js.js
│ │ │ ├── uri.js
│ │ │ ├── utf8.js
│ │ │ └── uuid.js
│ │ │ └── util
│ │ │ ├── Animation.js
│ │ │ ├── browser.js
│ │ │ ├── browserdetect.js
│ │ │ ├── jslint.js
│ │ │ ├── jsonSchema.js
│ │ │ ├── optparse.js
│ │ │ ├── path.js
│ │ │ ├── sizzle.js
│ │ │ ├── sprintf.js
│ │ │ ├── syntax.js
│ │ │ ├── underscore.js
│ │ │ └── wordWrap.js
│ ├── protocol.py
│ ├── server.py
│ ├── start.py
│ └── static
│ │ ├── Orbited2.js
│ │ ├── Orbited2.min.js
│ │ └── Orbited2.min.js.gz
└── setup.py
├── docs
├── CREDITS
├── Makefile
├── build
│ ├── doctrees
│ │ ├── compilation.doctree
│ │ ├── configuration.doctree
│ │ ├── deployment.doctree
│ │ ├── environment.pickle
│ │ ├── index.doctree
│ │ ├── intro.doctree
│ │ ├── tcpsocket.doctree
│ │ ├── under_the_hood.doctree
│ │ └── websocket.doctree
│ └── html
│ │ ├── .buildinfo
│ │ ├── _sources
│ │ ├── compilation.txt
│ │ ├── configuration.txt
│ │ ├── deployment.txt
│ │ ├── index.txt
│ │ └── intro.txt
│ │ ├── _static
│ │ ├── basic.css
│ │ ├── default.css
│ │ ├── docs.css
│ │ ├── doctools.js
│ │ ├── file.png
│ │ ├── init.js
│ │ ├── jquery.js
│ │ ├── minus.png
│ │ ├── plus.png
│ │ ├── pygments.css
│ │ └── searchtools.js
│ │ ├── compilation.html
│ │ ├── configuration.html
│ │ ├── deployment.html
│ │ ├── genindex.html
│ │ ├── index.html
│ │ ├── intro.html
│ │ ├── objects.inv
│ │ ├── search.html
│ │ └── searchindex.js
├── make.bat
└── source
│ ├── _static
│ ├── docs.css
│ └── init.js
│ ├── _templates
│ ├── genindex.mako
│ ├── layout.mako
│ ├── page.mako
│ ├── search.mako
│ ├── site_base.mako
│ └── static_base.mako
│ ├── builder
│ ├── __init__.py
│ ├── builders.py
│ └── util.py
│ ├── compilation.rst
│ ├── conf.py
│ ├── configuration.rst
│ ├── deployment.rst
│ ├── diagrams
│ ├── overview.graphml
│ └── overview.png
│ ├── index.rst
│ └── intro.rst
├── example_orbited2.cfg
├── site
├── docs
├── index.html
├── logo.png
├── orbited.css
├── orbited.txt
├── orbited_architecture.png
├── orbited_old_site.png
└── sites.html
└── tests
├── browser
├── Orbited2.js
├── Orbited2_raw.js
├── index.html
├── index_compiled.html
├── jsio
├── tcp_socket.html
└── tcp_socket_compiled.html
└── servers
└── eventlet
├── start.py
└── static
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.pyc
3 | *~
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Orbited2
2 | ========
3 |
4 | I have turned the reins to Orbited 0.7.x/0.8.x over to other developers, and there is plenty to do in order to stabilize that branch. As a side project, I'm interested in building a next-generation of Orbited which will just work out of the box, even more so than the last Orbited just worked. In particular, I want to solve all that legacy, cross-domain bs, and I want to offer two modes 1) tcp proxying, 2) websocket proxying.
5 |
6 | TCP Proxying improvments
7 | ------------------------
8 |
9 | - No more stupid domain hacks
10 | - Web-based admin panel
11 | - No @#$%@^ on-board STOMP.
12 |
13 | WebSocket proxying
14 | ------------------
15 |
16 | Why do we need a websocket proxy, you ask? Lets say you write a websocket server. Great, you now support chrome... and safari I suppose. But wait, which draft of websocket, 75? 76? And before ong, 77..? 88? Time to Write ten versions of your server, just to get the latest Webkit browers working.
17 |
18 | Instead, include Orbited.js, and call:
19 |
20 | Orbited.Websocket.install({
21 | proxyUri: "https://orbited.example.com:8001"
22 | protocolVersion: "rev76",
23 | forceProxy: true
24 | });
25 |
26 | Next you can just use the WebSocket api:
27 |
28 | var ws = new WebSocket();
29 | //etc.
30 |
31 | Now, you can simply code a rev76 websocket server, and Orbited will always do the right thing. If your browser supports that websocket, it will just use it. If it doesn't, it will proxy through orbited, transforming the protocol to the requested revision. Orbited will choose the best transport level protocol regardless of browser. Perhaps that transport will be script-tag longpolling (cross-domain IE6), or perhaps it will be WebSocket rev75 (Older chrome.) Maybe it will be flash. Who cares though, just write a WebSocket server and be done with it.
32 |
33 |
--------------------------------------------------------------------------------
/daemon/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include orbited2 *.js
2 | recursive-include orbited2 *.html
3 | recursive-include orbited2 *.css
4 | recursive-include orbited2 *.jpg
5 | recursive-include orbited2 *.png
6 | recursive-include orbited2 *.gif
7 |
--------------------------------------------------------------------------------
/daemon/orbited2/__init__.py:
--------------------------------------------------------------------------------
1 | __version__ = '2.0.b1'
2 |
--------------------------------------------------------------------------------
/daemon/orbited2/admin/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/daemon/orbited2/admin/__init__.py
--------------------------------------------------------------------------------
/daemon/orbited2/config.py:
--------------------------------------------------------------------------------
1 | from optparse import OptionParser
2 | import logging
3 | import sys
4 | from collections import defaultdict
5 |
6 | ALLOWED_INCOMING_PROTOCOLS = [ 'ws', 'csp' ]
7 |
8 | ALLOWED_REMOTE_PROTOCOLS = [ 'ws/hixie75', 'ws/hixie76', 'tcp' ]
9 |
10 |
11 |
12 | class ConfigException(Exception):
13 | pass
14 |
15 | class OrbitedConfig(object):
16 | logger = logging.getLogger('config')
17 | def __init__(self, args):
18 | config = self._parse_args(args)
19 | self._load_config(config)
20 |
21 | def _parse_args(self, args):
22 | parser = OptionParser()
23 | parser.add_option("-c", "--config", dest="config", type="string", default="./orbited2.cfg", metavar="PATH", help="Location of config file specified by PATH")
24 | options, args = parser.parse_args(args)
25 | return options.config
26 |
27 | def _load_config(self, dest):
28 | try:
29 | raw_config = open(dest, 'r').read()
30 | except IOError, e:
31 | self.logger.error("Could not load configuration file, %s" % (e,))
32 | sys.exit(1)
33 | exec(raw_config)
34 | """, {
35 | 'Listen': Listen,
36 | 'RemoteDestination': RemoteDestination
37 | })"""
38 | self.rules = ConfigBase.items
39 |
40 |
41 | class ConfigBase(object):
42 | items = defaultdict(lambda: [])
43 |
44 | def __init__(self, *args, **kwargs):
45 | self.items[self.__class__.__name__].append(self)
46 |
47 | def __repr__(self):
48 | import pprint
49 | pp = pprint.PrettyPrinter()
50 | return pp.pformat(self.__dict__)
51 |
52 | class Listen(ConfigBase):
53 | def __init__(self,
54 | port=8000,
55 | protocols=['ws', 'csp'],
56 | interface='127.0.0.1'
57 | ):
58 | ConfigBase.__init__(self)
59 | if not isinstance(port, int):
60 | raise Exception("port must be an integer")
61 | for protocol in protocols:
62 | if protocol not in ALLOWED_INCOMING_PROTOCOLS:
63 | raise Exception("protocol must be one of %s" % (ALLOWED_INCOMING_PROTOCOLS,))
64 | if not isinstance(interface, str):
65 | raise Exception("interface must be a string")
66 |
67 | self.port = port
68 | self.protocols = protocols
69 | self.interface=interface
70 |
71 | class RemoteDestination(ConfigBase):
72 | def __init__(self,
73 | name=None,
74 | hostname=None,
75 | port=None,
76 | host_header=None,
77 | protocol='ws/hixie76'
78 | ):
79 | ConfigBase.__init__(self)
80 | if not name:
81 | raise ConfigException("name required")
82 | if not isinstance(name, str):
83 | raise ConfigException("name must be a string")
84 |
85 | if not hostname:
86 | raise ConfigException("hostname required")
87 | if not isinstance(hostname, str):
88 | raise ConfigException("hostname must be a string")
89 |
90 | if not port:
91 | raise ConfigException("portrequired")
92 | if not isinstance(port, int):
93 | raise ConfigException("port must be an integer")
94 |
95 | if not host_header:
96 | raise ConfigException("host_header required")
97 | if not isinstance(host_header, str):
98 | raise ConfigException("host_header must be a string")
99 | if protocol not in ALLOWED_REMOTE_PROTOCOLS:
100 | raise ConfigException("invalid protocol, please choose one of: %s" % (ALLOWED_PROTOCOLS,))
101 |
102 | self.name = name
103 | self.hostname = hostname
104 | self.port = port
105 | self.host_header = host_header
106 | self.protocol = protocol
107 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/Makefile:
--------------------------------------------------------------------------------
1 | all: debug
2 |
3 | debug:
4 | jsio_compile Orbited2.pkg -j jsio-3.3alpha -o ../static/Orbited2.js -d
5 |
6 | release:
7 | jsio_compile Orbited2.pkg -j jsio-3.3alpha -o ../static/Orbited2.min.js -g --closure ./closure.jar
8 | cp ../static/Orbited2.min.js ../static/Orbited2.min.js.bak
9 | rm ../static/Orbited2.min.js.gz
10 | gzip ../static/Orbited2.min.js
11 | mv ../static/Orbited2.min.js.bak ../static/Orbited2.min.js
12 |
13 | clean:
14 | rm ../static/*.js
15 | rm ../static/*.js.gz
16 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/Orbited2.pkg:
--------------------------------------------------------------------------------
1 | {
2 | "root": "Orbited2",
3 | "externalName": "Orbited2",
4 | "transports": ["csp", "websocket"],
5 | "environments": ["browser"],
6 | "additional_dependancies": [ ]
7 | }
8 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/README:
--------------------------------------------------------------------------------
1 | To debug:
2 |
3 | `make debug`
4 |
5 | To release:
6 | (path to closure.jar must be specified in Makefile)
7 |
8 | `make release`
9 |
10 | Default:
11 |
12 | `make` with no arguments is the same as `make debug`
13 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/index.js:
--------------------------------------------------------------------------------
1 | // This is strictly for nodejs, not browsers.
2 | require('./jsio');
3 |
4 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/lib/Enum.js:
--------------------------------------------------------------------------------
1 | exports = function() {
2 | if (arguments.length == 1) {
3 | if (typeof arguments[0] == 'object') {
4 | var obj = arguments[0];
5 | for (var i in obj) {
6 | if (!(obj[i] in obj)) {
7 | obj[obj[i]] = i;
8 | }
9 | }
10 | return obj;
11 | } else if (typeof arguments[0] != 'string') {
12 | keys = arguments[0];
13 | }
14 | }
15 |
16 | if (!keys) { var keys = arguments; }
17 | var obj = {};
18 | for(var i = 0, len = keys.length; i < len; ++i) {
19 | if (keys[i]) {
20 | obj[keys[i]] = i + 1;
21 | }
22 | obj[i + 1] = keys[i];
23 | }
24 | return obj;
25 | }
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/lib/Hash.js:
--------------------------------------------------------------------------------
1 | /**
2 | * basic Hash/Set class
3 | * var h = new Hash('a', 'b', 'c');
4 | * h.contains('a') ==> true
5 | *
6 | * var h = new Hash({a: '1', b: '2', c: '3'});
7 | * h.contains('1') ==> true
8 | * h.hasKey('a') ==> true
9 | */
10 | exports = Class(function() {
11 | this.init = function() {
12 | this.m_keys = {};
13 | this.m_dict = {};
14 | this.m_values = {};
15 | if (arguments.length == 1 && typeof arguments == 'object') {
16 | var dict = arguments[0];
17 | for (var i in dict) {
18 | if (dict.hasOwnProperty(i)) {
19 | this.m_keys[i] = true;
20 | this.m_values[i] = dict[i];
21 | }
22 | }
23 | } else {
24 | for (var i = 0, len = arguments.length; i < len; i++) {
25 | this.m_keys[arguments[i]] = true;
26 | this.m_values[arguments[i]] = true;
27 | };
28 | }
29 | }
30 |
31 | this.contains = function(val) { return this.m_values.hasOwnProperty(val); }
32 | this.hasKey = this.containsKey = function(key) { return this.m_keys.hasOwnProperty(key); }
33 | this.each = function(f, ctx) {
34 | for (var i in keys) {
35 | if (this.m_keys.hasOwnProperty(i)) {
36 | f.call(ctx || GLOBAL, i, this.m_values[i], this);
37 | }
38 | }
39 | }
40 | });
41 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/lib/PubSub.js:
--------------------------------------------------------------------------------
1 | var ctx = jsio.__env.global;
2 |
3 | exports = Class(function() {
4 | this.publish = function(signal) {
5 | if(this._subscribers) {
6 | var args = Array.prototype.slice.call(arguments, 1);
7 | if(this._subscribers.__any) {
8 | var anyArgs = [signal].concat(args);
9 | for(var i = 0, sub; sub = this._subscribers.__any[i]; ++i) {
10 | sub.apply(ctx, args);
11 | }
12 | }
13 |
14 | if(!this._subscribers[signal]) { return; }
15 | for(var i = 0, sub; sub = this._subscribers[signal][i]; ++i) {
16 | sub.apply(ctx, args);
17 | }
18 | }
19 | return this;
20 | }
21 |
22 | this.subscribe = function(signal, ctx, method) {
23 | if(!this._subscribers) { this._subscribers = {}; }
24 | if(!this._subscribers[signal]) { this._subscribers[signal] = []; }
25 | var cb = bind.apply(ctx, Array.prototype.slice.call(arguments, 1));
26 | cb._ctx = ctx; // references for unsubscription
27 | cb._method = method;
28 | this._subscribers[signal].push(cb);
29 | return this;
30 | }
31 |
32 | // if no method is specified, all subscriptions with a callback context of ctx will be removed
33 | this.unsubscribe = function(signal, ctx, method) {
34 | var subs = this._subscribers[signal];
35 | for (var i = 0, c; c = subs[i]; ++i) {
36 | if (c._ctx == ctx && (!method || c._method == method)) {
37 | subs.splice(i--, 1);
38 | }
39 | }
40 | return this;
41 | }
42 | });
43 |
44 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/logging.js:
--------------------------------------------------------------------------------
1 | exports.UIWatcher = Class(function() {
2 |
3 | });
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net.js:
--------------------------------------------------------------------------------
1 | jsio('import net.env');
2 | jsio('import std.JSON as JSON');
3 |
4 | JSON.createGlobal(); // create the global JSON object if it doesn't already exist
5 |
6 | exports.listen = function(server, transportName, opts) {
7 | if (!transportName) {
8 | throw logger.error('No transport provided for net.listen');
9 | }
10 | var listenerClass = net.env.getListener(transportName);
11 | var listener = new listenerClass(server, opts);
12 | listener.listen();
13 | return listener;
14 | }
15 |
16 | exports.connect = function(protocolInstance, transportName, opts) {
17 | var ctor = net.env.getConnector(transportName),
18 | connector = new ctor(protocolInstance, opts);
19 |
20 | connector.connect();
21 | return connector;
22 | }
23 |
24 | exports.quickServer = function(protocolClass) {
25 | jsio('import net.interfaces');
26 | return new net.interfaces.Server(protocolClass);
27 | }
28 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/buffer.js:
--------------------------------------------------------------------------------
1 | jsio('from net.interfaces import Protocol');
2 |
3 | var EmptyBufferError = exports.EmptyBufferError = Class(function () {
4 | this.init = function(message) { this.message = message; }
5 | })
6 |
7 | exports.Buffer = Class(function(supr) {
8 |
9 | this.init = function(rawBuffer) {
10 |
11 | this._rawBuffer = !!rawBuffer ? rawBuffer : "";
12 | }
13 |
14 | this.getLength = function() {
15 | return this._rawBuffer.length;
16 | }
17 |
18 | this.append = function(data) {
19 | logger.debug('append', JSON.stringify(data));
20 | this._rawBuffer += data;
21 | }
22 |
23 | this.peekBytes = function(num) {
24 | if (!!num)
25 | return this._rawBuffer.slice(0, num);
26 | else
27 | return this._rawBuffer;
28 | }
29 |
30 | this.peekToDelimiter = function(delimiter) {
31 | delimiter = delimiter ? delimiter : '\n';
32 | var i = this._rawBuffer.indexOf(delimiter);
33 | if (i == -1)
34 | throw new EmptyBufferError("delimiter " + delimiter + "not present in buffer");
35 | else
36 | return this._rawBuffer.slice(0, i);
37 | }
38 |
39 | this.consumeBytes = function(num) {
40 | var output = this.peekBytes(num);
41 | this._rawBuffer = this._rawBuffer.slice(output.length);
42 | return output;
43 | }
44 | this.consumeMaxBytes = function(num) {
45 | var output = this._rawBuffer.slice(0, num);
46 | this._rawBuffer = this._rawBuffer(num);
47 | return output;
48 | }
49 | this.consumeAllBytes = function() {
50 | var temp = this._rawBuffer;
51 | this._rawBuffer = "";
52 | return temp;
53 | }
54 |
55 | this.consumeThroughDelimiter = function(delimiter) {
56 | return this.consumeToDelimiter(delimiter) + this.consumeBytes(delimiter.length);
57 | }
58 |
59 | this.consumeToDelimiter = function(delimiter) {
60 | delimiter = !!delimiter ? delimiter : "\n"
61 | var output = this.peekToDelimiter(delimiter);
62 | this._rawBuffer = this._rawBuffer.slice(output.length);
63 | return output;
64 | }
65 |
66 | this.hasBytes = function(num) {
67 | num = num ? num : 0;
68 | return this._rawBuffer.length >= num;
69 | }
70 |
71 | this.hasDelimiter = function(delimiter) {
72 | delimiter = !!delimiter ? delimiter : '\n';
73 | return (this._rawBuffer.indexOf(delimiter) != -1);
74 | }
75 |
76 | })
77 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env.js:
--------------------------------------------------------------------------------
1 | function getObj(objectName, transportName, envName) {
2 | try {
3 | jsio('from .env.' + (envName || jsio.__env.name) + '.' + transportName + ' import ' + objectName + ' as result');
4 | } catch(e) {
5 | throw logger.error('Invalid transport (', transportName, ') or environment (', envName, ')');
6 | }
7 | return result;
8 | }
9 |
10 | exports.getListener = bind(this, getObj, 'Listener');
11 | exports.getConnector = bind(this, getObj, 'Connector');
12 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/browser/csp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from net.csp.client import CometSession');
3 | jsio('import std.utf8 as utf8');
4 |
5 | exports.Connector = Class(net.interfaces.Connector, function() {
6 | this.connect = function() {
7 | this._state = net.interfaces.STATE.CONNECTING;
8 |
9 | var conn = new CometSession();
10 | conn.onconnect = bind(this, 'cometSessionOnConnect', conn);
11 | conn.ondisconnect = bind(this, 'onDisconnect');
12 |
13 | logger.debug('opening the connection');
14 | this._opts.encoding = 'plain';
15 | var url = this._opts.url;
16 | delete this._opts.url;
17 | conn.connect(url, this._opts);//{encoding: 'plain'});
18 | }
19 |
20 | this.cometSessionOnConnect = function(conn) {
21 | logger.debug('conn has opened');
22 | this.onConnect(new Transport(conn));
23 | }
24 | });
25 |
26 | var Transport = Class(net.interfaces.Transport, function() {
27 | this.init = function(conn) {
28 | this._conn = conn;
29 | }
30 |
31 | this.makeConnection = function(protocol) {
32 | this._conn.onread = bind(protocol, 'dataReceived');
33 | }
34 |
35 | this.write = function(data) {
36 | this._conn.write(this._encoding == 'utf8' ? utf8.encode(data) : data);
37 | }
38 |
39 | this.loseConnection = function(protocol) {
40 | this._conn.close();
41 | }
42 | });
43 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/browser/networkConsole.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
28 |
36 |
37 |
38 |
42 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/browser/postmessage.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from util.browser import $');
3 |
4 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
5 | var ID = 0;
6 |
7 | this.init = function() {
8 | supr(this, 'init', arguments);
9 | this._clients = {};
10 | if (!this._opts.clientUrl) {
11 | this._opts.clientUrl = jsio.__dir + '/networkConsole.html';
12 | }
13 | }
14 |
15 | this.listen = function() {
16 | $.onEvent(window, 'message', bind(this, '_onMessage'));
17 | }
18 |
19 | this.getButton = function(url, text) {
20 | var button = document.createElement('button');
21 | button.className = 'clientButton';
22 | button.innerHTML = text || 'launch client';
23 | $.onEvent(button, 'click', bind(this, '_openWindow', url));
24 | return button;
25 | }
26 |
27 | var uniqueId = 1;
28 | this._openWindow = function(url) {
29 | var options = { menubar: 'no', location: 'no', toolbar: 'no',
30 | width: 550, height: 350, // left: 200, top: 200,
31 | scrollbars: 'yes', status: 'yes', resizable: 'yes' };
32 |
33 | var arr = [];
34 | for (var i in options) { arr.push(i + '=' + options[i]) }
35 | var win = window.open(url, 'W' + uniqueId++, arr.join(','));
36 | win.focus();
37 | }
38 |
39 | this._onMessage = function(evt) {
40 | var name = evt.source.name;
41 | var target = this._clients[name];
42 | var data = eval('(' + evt.data + ')');
43 | switch (data.type) {
44 | case 'open':
45 | this._clients[name] = new exports.Transport(evt.source);
46 | evt.source.postMessage('{type:"open"}','*');
47 | this.onConnect(this._clients[name]);
48 | break;
49 | case 'data':
50 | target.onData(data.payload);
51 | break;
52 | case 'close':
53 | target.onClose();
54 | evt.source.postMessage('{type:"close"}','*');
55 | delete this._clients[name];
56 | break;
57 | }
58 | }
59 | });
60 |
61 | exports.Connector = Class(net.interfaces.Connector, function() {
62 | this.connect = function() {
63 | $.onEvent(window, 'message', bind(this, '_onMessage'));
64 | window.opener.postMessage(JSON.stringify({type:"open"}), '*');
65 | }
66 |
67 | this._onMessage = function(evt) {
68 | var data = eval('(' + evt.data + ')');
69 | switch(data.type) {
70 | case 'open':
71 | this._transport = new exports.Transport(evt.source);
72 | this.onConnect(this._transport);
73 | break;
74 | case 'close':
75 | this._transport.onClose();
76 | break;
77 | case 'data':
78 | this._transport.onData(data.payload);
79 | break;
80 | }
81 | }
82 | });
83 |
84 | exports.Transport = Class(net.interfaces.Transport, function() {
85 | this.init = function(win) {
86 | this._win = win;
87 | }
88 |
89 | this.makeConnection = function(protocol) {
90 | this._protocol = protocol;
91 | }
92 |
93 | this.write = function(data, encoding) {
94 | if (this.encoding == 'utf8') {
95 | this._win.postMessage(JSON.stringify({type: 'data', payload: utf8.encode(data)}), '*');
96 | } else {
97 | this._win.postMessage(JSON.stringify({type: 'data', payload: data}), '*');
98 | }
99 | }
100 |
101 | this.loseConnection = function(protocol) {
102 | this._win.postMessage(JSON.stringify({type: 'close', code: 301}), '*');
103 | }
104 |
105 | this.onData = function() { this._protocol.dataReceived.apply(this._protocol, arguments); }
106 | this.onClose = function() { this._protocol.connectionLost.apply(this._protocol, arguments); }
107 | });
108 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/browser/websocket.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('import std.utf8 as utf8');
3 | jsio('import net.errors as Errors');
4 |
5 | exports.Connector = Class(net.interfaces.Connector, function() {
6 | this.connect = function() {
7 | this._state = net.interfaces.STATE.CONNECTING;
8 |
9 | var url = this._opts.url,
10 | ctor = this._opts.wsConstructor || window.WebSocket;
11 |
12 | logger.info('this._opts', this._opts);
13 |
14 | var ws = new ctor(url);
15 | ws.onopen = bind(this, 'webSocketOnOpen', ws);
16 | ws.onclose = bind(this, 'webSocketOnClose', ws);
17 | }
18 |
19 | this.webSocketOnOpen = function(ws) {
20 | this.onConnect(new Transport(ws));
21 | }
22 |
23 | this.webSocketOnClose = function(ws, e) {
24 | var err,
25 | data = {rawError: e, webSocket: ws};
26 | if (e.wasClean) {
27 | err = new Errors.ServerClosedConnection('WebSocket Connection Closed', data);
28 | } else {
29 | if (this._state == net.interfaces.STATE.CONNECTED) {
30 | err = new Errors.ConnectionTimeout('WebSocket Connection Timed Out', data);
31 | } else {
32 | err = new Errors.ServerUnreachable('WebSocket Connection Failed', data);
33 | }
34 | }
35 |
36 | logger.debug('conn closed', err);
37 | this.onDisconnect(err);
38 | }
39 | });
40 |
41 | var Transport = Class(net.interfaces.Transport, function() {
42 |
43 | this.init = function(ws) {
44 | this._ws = ws;
45 | }
46 |
47 | this.makeConnection = function(protocol) {
48 | this._ws.onmessage = function(data) {
49 | var payload = utf8.encode(data.data);
50 | protocol.dataReceived(payload);
51 | }
52 | }
53 |
54 | this.write = function(data, encoding) {
55 | if (this._encoding == 'plain') {
56 | result = utf8.decode(data);
57 | data = result[0];
58 | }
59 | this._ws.send(data);
60 | }
61 |
62 | this.loseConnection = function(protocol) {
63 | this._ws.close();
64 | }
65 | });
66 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/node/csp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from .csp.server import createServer');
3 |
4 | var Transport = Class(net.interfaces.Transport, function() {
5 | this.init = function(socket) {
6 | this._socket = socket;
7 | logger.debug('init', socket);
8 | }
9 |
10 | this.makeConnection = function(protocol) {
11 | logger.debug('makeConnection:', protocol);
12 | this._socket.addListener("receive", bind(protocol, 'dataReceived'));
13 |
14 | this._socket.addListener("eof", this._socket.close);
15 | this._socket.addListener("close", bind(protocol, 'connectionLost')); // TODO: map error codes
16 | }
17 |
18 | this.write = function(data) {
19 | this._socket.send(data);
20 | }
21 |
22 | this.loseConnection = function() {
23 | this._socket.forceClose();
24 | }
25 | });
26 |
27 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
28 | this.listen = function() {
29 | var s = createServer(bind(this, function(socket) {
30 | logger.info("Incoming connection");
31 | socket.setEncoding("utf8");
32 | socket.addListener("connect", bind(this, function() {
33 | this.onConnect(new Transport(socket));
34 | }));
35 | }));
36 | this._cspServer = s;
37 | var listenString = (this._opts.interface || "" ) + ":" + this._opts.port;
38 | // TODO: Show class name
39 | if (!this._opts.skipListen) {
40 | logger.info("Listening csp@" + listenString);
41 | s.listen(this._opts.port, this._opts.interface || "");
42 | }
43 | }
44 | });
45 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/node/csp/util.js:
--------------------------------------------------------------------------------
1 | /*
2 | Helper functions, &c., for a comet server by Jacob Rus.
3 |
4 | --------------------
5 |
6 | Copyright (c) 2009 Jacob Rus
7 |
8 | Permission is hereby granted, free of charge, to any person
9 | obtaining a copy of this software and associated documentation
10 | files (the "Software"), to deal in the Software without
11 | restriction, including without limitation the rights to use,
12 | copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the
14 | Software is furnished to do so, subject to the following
15 | conditions:
16 |
17 | The above copyright notice and this permission notice shall be
18 | included in all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | // helper to test if string 2 is at the beginning of string 1
31 | exports.startswith = function (str1, str2) {
32 | return str1.substring(0, str2.length) == str2;
33 | };
34 |
35 | exports.JSIOError = Class(Error, function () {
36 | this.name = 'JSIOError';
37 | this.toString = Error.prototype.toString;
38 | this.init = function (message, fileName, lineNumber) {
39 | this.name = this.name; // promote class property to instance
40 | this.message = message || '';
41 | this.fileName = fileName || '«filename»'; // location.href; // XXX what should go here?
42 | this.lineNumber = isNaN(+lineNumber) ? 0 : +lineNumber
43 | };
44 | });
45 |
46 | exports.AssertionError = Class(exports.JSIOError, function (supr) {
47 | this.name = 'AssertionError'
48 | this.init = function () {supr(this, 'init', arguments)}
49 | });
50 |
51 | exports.assert = function (exp, message) {
52 | if (!exp) {
53 | throw new exports.AssertionError(message)
54 | };
55 | };
56 |
57 | // schedule a callback to run at the next available moment,
58 | // equivalent to setTimeout(callback, 0)
59 | exports.reschedule = function (callback) {
60 | return $setTimeout(callback, 0);
61 | };
62 |
63 | // cached static files
64 | exports.staticFile = (function(){
65 | var cache = {} // static file content indexed by filename
66 | var getfile = function(path, callback) {
67 | cacheContent = cache[path];
68 | if (cacheContent !== undefined) {
69 | // the file is in the cache, return it
70 | exports.reschedule(function(){
71 | callback(null, [cacheContent]);
72 | });
73 | } else {
74 | // load file from disk, save it in the cache, and return it
75 | process.fs.readFile(path, 'utf8', function(err, fileContent){
76 | if (err) {
77 | callback('staticFile readFile error ' + err)
78 | } else {
79 | cache[path] = fileContent;
80 | callback(null, [fileContent]);
81 | }
82 | })
83 | };
84 | return promise;
85 | };
86 | return getfile;
87 | })();
88 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/env/node/tcp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | var nodeTcp = jsio.__env.require('net');
4 |
5 | var Transport = Class(net.interfaces.Transport, function() {
6 | this.init = function(socket) {
7 | this._socket = socket;
8 | }
9 |
10 | this.makeConnection = function(protocol) {
11 | this._socket.addListener("data", bind(protocol, 'dataReceived'));
12 | this._socket.addListener("close", bind(protocol, 'connectionLost')); // TODO: map error codes
13 | this._socket.addListener("end", this._socket.close);
14 | }
15 |
16 | this.write = function(data) {
17 | this._socket.write(data);
18 | }
19 |
20 | this.loseConnection = function() {
21 | this._socket.forceClose();
22 | }
23 | });
24 |
25 |
26 | exports.Connector = Class(net.interfaces.Connector, function() {
27 | this.connect = function() {
28 |
29 | var conn = nodeTcp.createConnection(this._opts.port, this._opts.host);
30 | conn.addListener("connect", bind(this, function() {
31 | this.onConnect(new Transport(conn));
32 | }))
33 | // conn.addListener("close", bind(this, function() {
34 | // this.onDisconnect();
35 | // }))
36 | // conn.addListener("receive", bind(this._protocol, 'dataReceived'));
37 | this._opts.encoding = 'plain';
38 | conn.setEncoding("binary");
39 | if (typeof this._opts.timeout == 'number') { conn.setTimeout(this._opts.timeout); }
40 | }
41 | });
42 |
43 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
44 | this.listen = function() {
45 | var s = nodeTcp.createServer(bind(this, function(socket) {
46 | if (typeof this._opts.timeout == 'number') { socket.setTimeout(this._opts.timeout) }
47 | socket.setEncoding("utf8");
48 | socket.addListener("connect", bind(this, function() {
49 | this.onConnect(new Transport(socket));
50 | }));
51 | }));
52 | var listenString = (this._opts.interface || "" ) + ":" + this._opts.port;
53 | // TODO: Show class name
54 | logger.info("Listening tcp@" + listenString);
55 | s.listen(this._opts.port, this._opts.interface || "");
56 | }
57 | });
58 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/errors.js:
--------------------------------------------------------------------------------
1 | var makeErrorClass = function(name, _code) {
2 | var toString = function() {
3 | return name + (this.message ? ': ' + this.message : '');
4 | }
5 |
6 | var ctor = function(data) {
7 | if (typeof data == 'string') {
8 | this.message = data;
9 | } else {
10 | this.data = data;
11 | }
12 | }
13 |
14 | ctor.prototype = {
15 | type: name,
16 | toString: toString
17 | };
18 |
19 | return ctor;
20 | }
21 |
22 | exports.ReadyStateError = makeErrorClass("ReadyStateError");
23 | exports.InvalidEncodingError = makeErrorClass("InvalidEncodingError");
24 | exports.ExpiredSession = makeErrorClass("ExpiredSession");
25 |
26 | exports.ServerUnreachable = makeErrorClass("ServerUnreachable", 100);
27 | exports.ConnectionTimeout = makeErrorClass("ConnectionTimeout", 101);
28 |
29 | exports.ServerProtocolError = makeErrorClass("ServerProtocolError", 200);
30 |
31 | exports.ServerClosedConnection = makeErrorClass("ServerClosedConnection", 301);
32 | exports.ConnectionClosedCleanly = makeErrorClass("ConnectionClosedCleanly", 300);
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/interfaces.js:
--------------------------------------------------------------------------------
1 | // Sort of like a twisted protocol
2 | jsio('import net');
3 | jsio('import lib.Enum as Enum');
4 |
5 | var ctx = jsio.__env.global;
6 |
7 | exports.Protocol = Class(function() {
8 | this.connectionMade = function(isReconnect) {}
9 | this.dataReceived = function(data) {}
10 | this.connectionLost = function(reason) {}
11 | });
12 |
13 | exports.Client = Class(function() {
14 | this.init = function(protocol) {
15 | this._protocol = protocol;
16 | }
17 |
18 | this.connect = function(transportName, opts) {
19 | this._remote = new this._protocol();
20 | this._remote._client = this;
21 | net.connect(this._remote, transportName, opts);
22 | }
23 | });
24 |
25 | // Sort of like a twisted factory
26 | exports.Server = Class(function() {
27 | this.init = function(protocolClass) {
28 | this._protocolClass = protocolClass;
29 | }
30 |
31 | this.buildProtocol = function() {
32 | return new this._protocolClass();
33 | }
34 |
35 | this.listen = function(how, port) {
36 | return net.listen(this, how, port);
37 | }
38 | });
39 |
40 | exports.Transport = Class(function() {
41 | this._encoding = 'plain'
42 | this.write = function(data, encoding) {
43 | throw new Error("Not implemented");
44 | }
45 | this.getPeer = function() {
46 | throw new Error("Not implemented");
47 | }
48 | this.setEncoding = function(encoding) {
49 | this._encoding = encoding;
50 | }
51 | this.getEncoding = function() {
52 | return this._encoding;
53 | }
54 | });
55 |
56 | exports.Listener = Class(function() {
57 | this.init = function(server, opts) {
58 | this._server = server;
59 | this._opts = opts || {};
60 | }
61 |
62 | this.onConnect = function(transport) {
63 | // try {
64 | var p = this._server.buildProtocol();
65 | p.transport = transport;
66 | p.server = this._server;
67 | transport.protocol = p;
68 | transport.makeConnection(p);
69 | p.connectionMade();
70 | // } catch(e) {
71 | // logger.error(e);
72 | // }
73 | }
74 |
75 | this.listen = function() { throw new Error('Abstract class'); }
76 | this.stop = function() {}
77 | });
78 |
79 | exports.STATE = Enum('INITIAL', 'DISCONNECTED', 'CONNECTING', 'CONNECTED');
80 | exports.Connector = Class(function() {
81 | this.init = function(protocol, opts) {
82 | this._protocol = protocol;
83 | this._opts = opts;
84 | this._state = exports.STATE.INITIAL;
85 | }
86 |
87 | this.onConnect = function(transport) {
88 | this._state = exports.STATE.CONNECTED;
89 |
90 | transport.makeConnection(this._protocol);
91 | this._protocol.transport = transport;
92 | try {
93 | this._protocol.connectionMade();
94 | } catch(e) {
95 | throw logger.error(e);
96 | }
97 | }
98 |
99 | this.onDisconnect = function(err) {
100 | var wasConnected = this._state == exports.STATE.CONNECTED;
101 | this._state = exports.STATE.DISCONNECTED;
102 |
103 | try {
104 | this._protocol.connectionLost(err, wasConnected);
105 | } catch(e) {
106 | throw logger.error(e);
107 | }
108 | }
109 |
110 | this.getProtocol = function() { return this._protocol; }
111 | });
112 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/later.js:
--------------------------------------------------------------------------------
1 | exports.Later = Class(function() {
2 | this.init = function() {
3 | this.cb = null
4 | this.eb = null
5 | this.values = []
6 | this.errors = []
7 | this.cancelback = null;
8 | }
9 |
10 | this.succeed = function(data) {
11 | this.callback(data);
12 | }
13 |
14 | this.callback = function() {
15 | logger.debug('callback', [].slice.call(arguments, 0));
16 | if (this.cb) {
17 | var result = this.cb.apply(this, arguments);
18 | if (result == false) {
19 | this.cancel();
20 | }
21 | } else {
22 | this.values.push(arguments);
23 | }
24 | }
25 |
26 | this.errback = function() {
27 | logger.debug('eb', [].slice.call(arguments, 0));
28 | if (this.eb) {
29 | this.eb.apply(this, arguments);
30 | }
31 | else {
32 | this.errors.push(arguments);
33 | }
34 | }
35 |
36 | this.cancel = function() {
37 | if (this.cancelback) {
38 | var cb = this.cancelback;
39 | this.cancelback = null;
40 | cb.call(this);
41 | }
42 | }
43 | this.setCallback = function(cb) {
44 | this.cb = cb;
45 | for (var i = 0, v; v=this.values[i]; ++i) {
46 | this.cb.apply(this, v);
47 | }
48 | this.values = [];
49 | return this;
50 | }
51 | this.setErrback = function(eb) {
52 | this.eb = eb;
53 | for (var i = 0, v; e=this.errors[i]; ++i) {
54 | this.eb.apply(this, e);
55 | }
56 | this.errors = [];
57 | return this;
58 | }
59 | this.setCancelback = function(cancelback) {
60 | this.cancelback = cancelback;
61 | return this;
62 | }
63 | })
64 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/protocols/buffered.js:
--------------------------------------------------------------------------------
1 | jsio('from net.interfaces import Protocol');
2 | jsio('from net.buffer import Buffer');
3 |
4 | exports.BufferedProtocol = Class(Protocol, function(supr) {
5 |
6 | this.init = function() {
7 | this.buffer = new Buffer();
8 | }
9 |
10 | // Overwrite this instead of dataReceived in base classes
11 | this.bufferUpdated = function() {}
12 |
13 | this.dataReceived = function(data) {
14 | this.buffer.append(data);
15 | this.bufferUpdated();
16 | }
17 |
18 | })
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/protocols/delimited.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | exports.DelimitedProtocol = Class(net.interfaces.Protocol, function(supr) {
4 |
5 | this.init = function(delimiter) {
6 | if (!delimiter) {
7 | delimiter = '\r\n'
8 | }
9 | this.delimiter = delimiter;
10 | this.buffer = ""
11 | }
12 |
13 | this.connectionMade = function() {
14 | logger.debug('connectionMade');
15 | }
16 |
17 | this.dataReceived = function(data) {
18 | if (!data) { return; }
19 | logger.debug('dataReceived:(' + data.length + ')', data);
20 | logger.debug('last 2:', data.slice(data.length-2));
21 | this.buffer += data;
22 | logger.debug('index', this.buffer.indexOf(this.delimiter));
23 | var i;
24 | while ((i = this.buffer.indexOf(this.delimiter)) != -1) {
25 | var line = this.buffer.slice(0, i);
26 | this.buffer = this.buffer.slice(i + this.delimiter.length);
27 | this.lineReceived(line);
28 | }
29 | }
30 |
31 | this.lineReceived = function(line) {
32 | logger.debug('Not implemented, lineReceived:', line);
33 | }
34 | this.sendLine = function(line) {
35 | logger.debug('WRITE:', line + this.delimiter);
36 | this.transport.write(line + this.delimiter);
37 | }
38 | this.connectionLost = function() {
39 | logger.debug('connectionLost');
40 | }
41 | });
42 |
43 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/protocols/echo.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | exports.Protocol = Class(net.interfaces.Protocol, function() {
4 | this.connectionMade = function() {
5 | logger.debug('in connectionMade');
6 | this.transport.write('Welcome')
7 | }
8 |
9 | this.dataReceived = function(data) {
10 | logger.debug('dataReceived:', data);
11 | this.transport.write('Echo: ' + data);
12 | }
13 | this.connectionLost = function() {
14 | logger.debug('conn lost');
15 | }
16 | });
17 |
18 | exports.Server = Class(net.interfaces.Server, function(supr) {
19 | this.init = function() {
20 | supr(this, 'init', [exports.Protocol]);
21 | }
22 | });
23 |
24 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/net/protocols/rtjp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from net.protocols.delimited import DelimitedProtocol');
3 |
4 | exports.RTJPProtocol = Class(DelimitedProtocol, function(supr) {
5 | this.init = function() {
6 | var delimiter = '\r\n';
7 | supr(this, 'init', [delimiter]);
8 | this.frameId = 0;
9 | }
10 |
11 | this.connectionMade = function() {
12 | logger.debug("connectionMade");
13 | }
14 |
15 | var error = function(e) {
16 | logger.error(e);
17 | }
18 |
19 | // Inherit and overwrite
20 | this.frameReceived = function(id, name, args) {
21 | }
22 |
23 | // Public
24 | this.sendFrame = function(name, args) {
25 | if (!args) {
26 | args = {}
27 | }
28 | logger.debug('sendFrame', name, args);
29 | this.sendLine(JSON.stringify([++this.frameId, name, args]));
30 | return this.frameId;
31 | }
32 |
33 | this.lineReceived = function(line) {
34 | try {
35 | var frame = JSON.parse(line);
36 | if (frame.length != 3) {
37 | return error.call(this, "Invalid frame length");
38 | }
39 | if (typeof(frame[0]) != "number") {
40 | return error.call(this, "Invalid frame id");
41 | }
42 | if (typeof(frame[1]) != "string") {
43 | return error.call(this, "Invalid frame name");
44 | }
45 | logger.debug("frameReceived:", frame[0], frame[1], frame[2]);
46 | this.frameReceived(frame[0], frame[1], frame[2]);
47 | } catch(e) {
48 | error.call(this, e);
49 | }
50 | }
51 |
52 | this.connectionLost = function() {
53 | logger.debug('conn lost');
54 | }
55 | });
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/std/base64.js:
--------------------------------------------------------------------------------
1 | /*
2 | "URL-safe" Base64 Codec, by Jacob Rus
3 |
4 | This library happily strips off as many trailing '=' as are included in the
5 | input to 'decode', and doesn't worry whether its length is an even multiple
6 | of 4. It does not include trailing '=' in its own output. It uses the
7 | 'URL safe' base64 alphabet, where the last two characters are '-' and '_'.
8 |
9 | --------------------
10 |
11 | Copyright (c) 2009 Jacob Rus
12 |
13 | Permission is hereby granted, free of charge, to any person
14 | obtaining a copy of this software and associated documentation
15 | files (the "Software"), to deal in the Software without
16 | restriction, including without limitation the rights to use,
17 | copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the
19 | Software is furnished to do so, subject to the following
20 | conditions:
21 |
22 | The above copyright notice and this permission notice shall be
23 | included in all copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
27 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
29 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
30 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32 | OTHER DEALINGS IN THE SOFTWARE.
33 | */
34 |
35 | var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
36 | var pad = '=';
37 | var padChar = alphabet.charAt(alphabet.length - 1);
38 |
39 | var shorten = function (array, number) {
40 | // remove 'number' characters from the end of 'array', in place (no return)
41 | for (var i = number; i > 0; i--){ array.pop(); };
42 | };
43 |
44 | var decode_map = {};
45 | for (var i=0, n=alphabet.length; i < n; i++) {
46 | decode_map[alphabet.charAt(i)] = i;
47 | };
48 |
49 |
50 | // use this regexp in the decode function to sniff out invalid characters.
51 | var alphabet_inverse = new RegExp('[^' + alphabet.replace('-', '\\-') + ']');
52 |
53 |
54 |
55 | var Base64CodecError = exports.Base64CodecError = function (message) {
56 | this.message = message;
57 | };
58 | Base64CodecError.prototype.toString = function () {
59 | return 'Base64CodecError' + (this.message ? ': ' + this.message : '');
60 | };
61 |
62 | var assertOrBadInput = function (exp, message) {
63 | if (!exp) { throw new Base64CodecError(message) };
64 | };
65 |
66 | exports.encode = function (bytes) {
67 | assertOrBadInput(!(/[^\x00-\xFF]/.test(bytes)), // disallow two-byte chars
68 | 'Input contains out-of-range characters.');
69 | var padding = '\x00\x00\x00'.slice((bytes.length % 3) || 3);
70 | bytes += padding; // pad with null bytes
71 | var out_array = [];
72 | for (var i=0, n=bytes.length; i < n; i+=3) {
73 | var newchars = (
74 | (bytes.charCodeAt(i) << 020) +
75 | (bytes.charCodeAt(i+1) << 010) +
76 | (bytes.charCodeAt(i+2)));
77 | out_array.push(
78 | alphabet.charAt((newchars >> 18) & 077),
79 | alphabet.charAt((newchars >> 12) & 077),
80 | alphabet.charAt((newchars >> 6) & 077),
81 | alphabet.charAt((newchars) & 077));
82 | };
83 | shorten(out_array, padding.length);
84 | return out_array.join('');
85 | };
86 |
87 | exports.decode = function (b64text) {
88 | logger.debug('decode', b64text);
89 | b64text = b64text.replace(/\s/g, '') // kill whitespace
90 | // strip trailing pad characters from input; // XXX maybe some better way?
91 | var i = b64text.length; while (b64text.charAt(--i) === pad) {}; b64text = b64text.slice(0, i + 1);
92 | assertOrBadInput(!alphabet_inverse.test(b64text), 'Input contains out-of-range characters.');
93 | var padding = Array(5 - ((b64text.length % 4) || 4)).join(padChar);
94 | b64text += padding; // pad with last letter of alphabet
95 | var out_array = [];
96 | for (var i=0, n=b64text.length; i < n; i+=4) {
97 | newchars = (
98 | (decode_map[b64text.charAt(i)] << 18) +
99 | (decode_map[b64text.charAt(i+1)] << 12) +
100 | (decode_map[b64text.charAt(i+2)] << 6) +
101 | (decode_map[b64text.charAt(i+3)]));
102 | out_array.push(
103 | (newchars >> 020) & 0xFF,
104 | (newchars >> 010) & 0xFF,
105 | (newchars) & 0xFF);
106 | };
107 | shorten(out_array, padding.length);
108 | var result = String.fromCharCode.apply(String, out_array);
109 | logger.debug('decoded', result);
110 | return result;
111 | };
112 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/std/js.js:
--------------------------------------------------------------------------------
1 | exports.vargs = function(args, n) { return Array.prototype.slice.call(args, n || 0); }
2 | exports.isArray = function(input) { return Object.prototype.toString.call(input) === '[object Array]'; }
3 |
4 | exports.shallowCopy = function(input) {
5 | if (exports.isArray(input)) {
6 | return input.slice(0);
7 | } else {
8 | var out = {};
9 | for (var key in input) {
10 | if (input.hasOwnProperty(key)) {
11 | out[key] = input[key];
12 | }
13 | }
14 | }
15 |
16 | return out;
17 | }
18 |
19 | exports.merge = function(base, extra) {
20 | base = base || {};
21 |
22 | for (var key in extra) {
23 | if (extra.hasOwnProperty(key) && !base.hasOwnProperty(key)) {
24 | base[key] = extra[key];
25 | }
26 | }
27 |
28 | return base;
29 | }
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/std/uri.js:
--------------------------------------------------------------------------------
1 | var attrs = [
2 | "source",
3 | "protocol",
4 | "authority",
5 | "userInfo",
6 | "user",
7 | "password",
8 | "host",
9 | "port",
10 | "relative",
11 | "path",
12 | "directory",
13 | "file",
14 | "query",
15 | "anchor"
16 | ];
17 |
18 | exports.Uri = Class(function(supr) {
19 | this.init = function(url, isStrict) {
20 | var uriData = exports.parse(url, isStrict)
21 | for (attr in uriData) {
22 | this['_' + attr] = uriData[attr];
23 | };
24 | };
25 |
26 | for (var i = 0, attr; attr = attrs[i]; ++i) {
27 | (function(attr) {
28 | var fNameSuffix = attr.charAt(0).toUpperCase() + attr.slice(1);
29 | this['get' + fNameSuffix] = function() {
30 | return this['_' + attr];
31 | };
32 | this['set' + fNameSuffix] = function(val) {
33 | this['_' + attr] = val;
34 | };
35 | }).call(this, attr);
36 | };
37 |
38 | this.toString = this.render = function() {
39 | // XXX TODO: This is vaguely reasonable, but not complete. fix it...
40 | var a = this._protocol ? this._protocol + "://" : ""
41 | var b = this._host ? this._host + ((this._port || 80) == 80 ? "" : ":" + this._port) : "";
42 | var c = this._path;
43 | var d = this._query ? '?' + this._query : '';
44 | var e = this._anchor ? '#' + this._anchor : '';
45 | return a + b + c + d + e;
46 | };
47 | });
48 |
49 | exports.buildQuery = function(kvp) {
50 | var pairs = [];
51 | for (key in kvp) {
52 | pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(kvp[key]));
53 | }
54 | return pairs.join('&');
55 | }
56 |
57 | exports.parseQuery = function(str) {
58 | var pairs = str.split('&'),
59 | n = pairs.length,
60 | data = {};
61 | for (var i = 0; i < n; ++i) {
62 | var pair = pairs[i].split('='),
63 | key = decodeURIComponent(pair[0]);
64 | if (key) { data[key] = decodeURIComponent(pair[1]); }
65 | }
66 | return data;
67 | }
68 |
69 | // Regexs are based on parseUri 1.2.2
70 | // Original: (c) Steven Levithan
71 | // Original: MIT License
72 |
73 | var strictRegex = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/;
74 | var looseRegex = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
75 | var queryStringRegex = /(?:^|&)([^&=]*)=?([^&]*)/g;
76 |
77 | exports.parse = function(str, isStrict) {
78 | var regex = isStrict ? strictRegex : looseRegex;
79 | var result = {};
80 | var match = regex.exec(str);
81 | for (var i = 0, attr; attr = attrs[i]; ++i) {
82 | result[attr] = match[i] || "";
83 | }
84 |
85 | var qs = result['queryKey'] = {};
86 | result['query'].replace(queryStringRegex, function(check, key, val) {
87 | if (check) {
88 | qs[key] = val;
89 | }
90 | });
91 |
92 | return result;
93 | }
94 |
95 | exports.isSameDomain = function(urlA, urlB) {
96 | var a = exports.parse(urlA);
97 | var b = exports.parse(urlB);
98 | return ((a.port == b.port ) && (a.host == b.host) && (a.protocol == b.protocol));
99 | };
100 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/std/utf8.js:
--------------------------------------------------------------------------------
1 | /*
2 | Fast incremental JavaScript UTF-8 encoder/decoder, by Jacob Rus.
3 |
4 | API for decode from Orbited: as far as I know, the first incremental
5 | JavaScript UTF-8 decoder.
6 |
7 | Inspired by the observation by Johan Sundström published at:
8 | http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html
9 |
10 | Note that this code throws an error for invalid UTF-8. Because it is so much
11 | faster than previous implementations, the recommended way to do lenient
12 | parsing is to first try this decoder, and then fall back on a slower lenient
13 | decoder if necessary for the particular use case.
14 |
15 | --------------------
16 |
17 | Copyright (c) 2009 Jacob Rus
18 |
19 | Permission is hereby granted, free of charge, to any person
20 | obtaining a copy of this software and associated documentation
21 | files (the "Software"), to deal in the Software without
22 | restriction, including without limitation the rights to use,
23 | copy, modify, merge, publish, distribute, sublicense, and/or sell
24 | copies of the Software, and to permit persons to whom the
25 | Software is furnished to do so, subject to the following
26 | conditions:
27 |
28 | The above copyright notice and this permission notice shall be
29 | included in all copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
33 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
35 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
36 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
38 | OTHER DEALINGS IN THE SOFTWARE.
39 | */
40 | //var utf8 = this.utf8 = exports;
41 |
42 | exports.UnicodeCodecError = function (message) {
43 | this.message = message;
44 | };
45 |
46 | var UnicodeCodecError = exports.UnicodeCodecError;
47 |
48 | UnicodeCodecError.prototype.toString = function () {
49 | return 'UnicodeCodecError' + (this.message ? ': ' + this.message : '');
50 | };
51 |
52 | exports.encode = function (unicode_string) {
53 | // Unicode encoder: Given an arbitrary unicode string, returns a string
54 | // of characters with code points in range 0x00 - 0xFF corresponding to
55 | // the bytes of the utf-8 representation of those characters.
56 | try {
57 | return unescape(encodeURIComponent(unicode_string));
58 | }
59 | catch (err) {
60 | throw new UnicodeCodecError('invalid input string');
61 | };
62 | };
63 | exports.decode = function (bytes) {
64 | // Unicode decoder: Given a string of characters with code points in
65 | // range 0x00 - 0xFF, which, when interpreted as bytes, are valid UTF-8,
66 | // returns the corresponding Unicode string, along with the number of
67 | // bytes in the input string which were successfully parsed.
68 | //
69 | // Unlike most JavaScript utf-8 encode/decode implementations, properly
70 | // deals with partial multi-byte characters at the end of the byte string.
71 | if (/[^\x00-\xFF]/.test(bytes)) {
72 | throw new UnicodeCodecError('invalid utf-8 bytes');
73 | };
74 | var len, len_parsed;
75 | len = len_parsed = bytes.length;
76 | var last = len - 1;
77 | // test for non-ascii final byte. if last byte is ascii (00-7F) we're done.
78 | if (bytes.charCodeAt(last) >= 0x80) {
79 | // loop through last 3 bytes looking for first initial byte of unicode
80 | // multi-byte character. If the initial byte is 4th from the end, we'll
81 | // parse the whole string.
82 | for (var i = 1; i <= 3; i++) {
83 | // initial bytes are in range C0-FF
84 | if (bytes.charCodeAt(len - i) >= 0xC0) {
85 | len_parsed = len - i;
86 | break;
87 | };
88 | };
89 | try {
90 | // if the last few bytes are a complete multi-byte character, parse
91 | // everything (by setting len_parsed)
92 | decodeURIComponent(escape(bytes.slice(len_parsed)));
93 | len_parsed = len;
94 | }
95 | catch (err) { /* pass */ };
96 | };
97 | try {
98 | return [
99 | decodeURIComponent(escape(bytes.slice(0, len_parsed))),
100 | len_parsed
101 | ];
102 | }
103 | catch (err) {
104 | throw new UnicodeCodecError('invalid utf-8 bytes');
105 | };
106 | };
107 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/std/uuid.js:
--------------------------------------------------------------------------------
1 | /*
2 | Based on Math.uuid.js 1.4 by Robert Kieffer
3 |
4 | ----
5 | Copyright (c) 2008, Robert Kieffer
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 |
11 | * Redistributions of source code must retain the above copyright notice,
12 | this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 | * Neither the name of Robert Kieffer nor the names of its contributors
17 | may be used to endorse or promote products derived from this software
18 | without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 | POSSIBILITY OF SUCH DAMAGE.
31 |
32 | */
33 |
34 |
35 |
36 | /*
37 | * Generate a random uuid.
38 | *
39 | * USAGE: uuid.uuid(length, radix)
40 | * length - the desired number of characters
41 | * radix - the number of allowable values for each character.
42 | *
43 | * EXAMPLES:
44 | * // No arguments - returns RFC4122, version 4 ID
45 | * >>> Math.uuid()
46 | * "92329D39-6F5C-4520-ABFC-AAB64544E172"
47 | *
48 | * // One argument - returns ID of the specified length
49 | * >>> Math.uuid(15) // 15 character ID (default base=62)
50 | * "VcydxgltxrVZSTV"
51 | *
52 | * // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
53 | * >>> Math.uuid(8, 2) // 8 character ID (base=2)
54 | * "01001010"
55 | * >>> Math.uuid(8, 10) // 8 character ID (base=10)
56 | * "47473046"
57 | * >>> Math.uuid(8, 16) // 8 character ID (base=16)
58 | * "098F4D35"
59 | */
60 |
61 |
62 | var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
63 | exports.uuid = function (len, radix) {
64 | var chars = CHARS, uuid = [], rnd = Math.random;
65 | radix = radix || chars.length;
66 |
67 | if (len) {
68 | // Compact form
69 | for (var i = 0; i < len; i++) uuid[i] = chars[0 | rnd()*radix];
70 | } else {
71 | // rfc4122, version 4 form
72 | var r;
73 |
74 | // rfc4122 requires these characters
75 | uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
76 | uuid[14] = '4';
77 |
78 | // Fill in random data. At i==19 set the high bits of clock sequence as
79 | // per rfc4122, sec. 4.1.5
80 | for (var i = 0; i < 36; i++) {
81 | if (!uuid[i]) {
82 | r = 0 | rnd()*16;
83 | uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
84 | }
85 | }
86 | }
87 | return uuid.join('');
88 | };
89 |
90 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.2/util/browserdetect.js:
--------------------------------------------------------------------------------
1 | exports.BrowserDetect = new function() {
2 | var versionSearchString;
3 | var dataBrowser = [
4 | {
5 | string: navigator.userAgent,
6 | subString: "Chrome"
7 | },
8 | {
9 | string: navigator.userAgent,
10 | subString: "OmniWeb",
11 | versionSearch: "OmniWeb/"
12 | },
13 | {
14 | string: navigator.vendor,
15 | subString: "Apple",
16 | identity: "Safari",
17 | versionSearch: "Version"
18 | },
19 | {
20 | prop: window.opera,
21 | identity: "Opera"
22 | },
23 | {
24 | string: navigator.vendor,
25 | subString: "iCab"
26 | },
27 | {
28 | string: navigator.vendor,
29 | subString: "KDE",
30 | identity: "Konqueror"
31 | },
32 | {
33 | string: navigator.userAgent,
34 | subString: "Firefox"
35 | },
36 | {
37 | string: navigator.vendor,
38 | subString: "Camino"
39 | },
40 | { // for newer Netscapes (6+)
41 | string: navigator.userAgent,
42 | subString: "Netscape"
43 | },
44 | {
45 | string: navigator.userAgent,
46 | subString: "MSIE",
47 | identity: "IE",
48 | versionSearch: "MSIE"
49 | },
50 | {
51 | string: navigator.userAgent,
52 | subString: "Gecko",
53 | identity: "Mozilla",
54 | versionSearch: "rv"
55 | },
56 | { // for older Netscapes (4-)
57 | string: navigator.userAgent,
58 | subString: "Mozilla",
59 | identity: "Netscape",
60 | versionSearch: "Mozilla"
61 | }
62 | ];
63 |
64 | var dataOS = [
65 | {
66 | string: navigator.platform,
67 | subString: "Win",
68 | identity: "Windows"
69 | },
70 | {
71 | string: navigator.platform,
72 | subString: "Mac"
73 | },
74 | {
75 | string: navigator.userAgent,
76 | subString: "iPhone",
77 | identity: "iPhone/iPod"
78 | },
79 | {
80 | string: navigator.platform,
81 | subString: "Linux"
82 | }
83 | ];
84 |
85 | function searchString(data) {
86 | for (var i=0,item;item=data[i];i++) {
87 | var dataString = item.string;
88 | var dataProp = item.prop;
89 | item.identity = item.identity || item.subString;
90 | versionSearchString = item.versionSearch || item.identity;
91 | if (dataString) {
92 | if (dataString.indexOf(item.subString) != -1)
93 | return item.identity;
94 | } else if (dataProp)
95 | return item.identity;
96 | }
97 | }
98 |
99 | function searchVersion(dataString) {
100 | var index = dataString.indexOf(versionSearchString);
101 | if (index == -1) return;
102 | return parseFloat(dataString.substring(index+versionSearchString.length+1));
103 | }
104 |
105 | this.browser = searchString(dataBrowser) || "unknown";
106 | this.version = searchVersion(navigator.userAgent)
107 | || searchVersion(navigator.appVersion)
108 | || "unknown";
109 | this.OS = searchString(dataOS) || "unknown";
110 | this.isWebKit = RegExp(" AppleWebKit/").test(navigator.userAgent);
111 | this['is'+this.browser] = this.version;
112 | };
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/index.js:
--------------------------------------------------------------------------------
1 | // This is strictly for nodejs, not browsers.
2 | require('./jsio');
3 |
4 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/Callback.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import std.js as JS;
4 |
5 | exports = Class(function() {
6 | this.init = function() {
7 | this._fired = false;
8 | this._run = [];
9 | this._id = 0;
10 | this._pending = 0;
11 | this._stat = {};
12 | }
13 |
14 | this.fired = function() { return this._fired; }
15 | this.reset = function() { this._args = []; this._fired = false; }
16 |
17 | this.forward = function(arguments) { this.run.apply(this, arguments); }
18 | this.run = function(ctx, method) {
19 | var f = method ? bind.apply(this, arguments) : ctx;
20 | if (f) {
21 | if (this._fired) {
22 | f.apply(this, this._args);
23 | } else {
24 | this._run.push(f);
25 | }
26 | }
27 | return this;
28 | }
29 |
30 | this.fire = function() {
31 | if (this._fired) { return; }
32 | this._fired = true;
33 |
34 | var cbs = this._run;
35 | this._run = [];
36 | this._args = arguments;
37 | for(var i = 0, len = cbs.length; i < len; ++i) {
38 | if (cbs[i]) { cbs[i].apply(this, arguments); }
39 | }
40 | }
41 |
42 | this.chain = function(id) {
43 | ++this._pending;
44 | this.reset();
45 | return bind(this, '_deferred', id || (this._id++));
46 | }
47 |
48 | this._deferred = function(id) {
49 | if (this._stat.hasOwnProperty(id)) { return; }
50 |
51 | this._stat[id] = JS.vargs(arguments, 1);
52 | if (this._pending) { --this._pending; }
53 | if (!this._pending) { this.fire(this._stat); }
54 | }
55 | });
56 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/Enum.js:
--------------------------------------------------------------------------------
1 | exports = function() {
2 | if (arguments.length == 1) {
3 | if (typeof arguments[0] == 'object') {
4 | var obj = arguments[0];
5 | for (var i in obj) {
6 | if (!(obj[i] in obj)) {
7 | obj[obj[i]] = i;
8 | }
9 | }
10 | return obj;
11 | } else if (typeof arguments[0] != 'string') {
12 | keys = arguments[0];
13 | }
14 | }
15 |
16 | if (!keys) { var keys = arguments; }
17 | var obj = {};
18 | for(var i = 0, len = keys.length; i < len; ++i) {
19 | if (keys[i]) {
20 | obj[keys[i]] = i + 1;
21 | }
22 | obj[i + 1] = keys[i];
23 | }
24 | return obj;
25 | }
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/Hash.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Summary: a basic Hash/Set class for number and string values.
3 | * Methods:
4 | * - init(args...) - if args is a single JS object, this will be used to define
5 | * the keys and values for the Hash.
6 | * - contains(value)
7 | * Example:
8 | * var h = new Hash('a', 'b', 'c');
9 | * h.contains('a') ==> true
10 | *
11 | * var h = new Hash({a: '1', b: '2', c: '3'});
12 | * h.contains('1') ==> true
13 | * h.hasKey('a') ==> true
14 | */
15 | exports = Class(function() {
16 | this.init = function() {
17 | this._keys = {};
18 | this._dict = {};
19 | this._values = {};
20 | if (arguments.length == 1 && typeof arguments == 'object') {
21 | var dict = arguments[0];
22 | for (var i in dict) {
23 | if (dict.hasOwnProperty(i)) {
24 | this._keys[i] = true;
25 | this._values[i] = dict[i];
26 | }
27 | }
28 | } else {
29 | for (var i = 0, len = arguments.length; i < len; i++) {
30 | this._keys[arguments[i]] = true;
31 | this._values[arguments[i]] = true;
32 | };
33 | }
34 | }
35 |
36 | this.contains = function(val) { return this._values.hasOwnProperty(val); }
37 | this.hasKey = this.containsKey = function(key) { return this._keys.hasOwnProperty(key); }
38 | this.each = function(f, ctx) {
39 | for (var i in keys) {
40 | if (this._keys.hasOwnProperty(i)) {
41 | f.call(ctx || GLOBAL, i, this._values[i], this);
42 | }
43 | }
44 | }
45 | });
46 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/Iterator.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | /**
4 | * Summary: Provides an object for iterating over the keys and values of
5 | * an object or array.
6 | * Methods:
7 | * - init(src) - src is the object to iterate over
8 | * - next(): returns the current value and advances the iterator to the next value
9 | * - loop(cb): iterate over all items immediately, calling cb with each item
10 | * - asyncLoop(cb): iterate over all items asynchronously. First argument to
11 | * the callback is the item. Second argument is a function `nextItem` that,
12 | * when called, will cause the iterator to advance to the next element and
13 | * call cb again.
14 | * Usage notes: asyncLoop is implemented to not be vulnerable to stack overflows.
15 | * If cb immediately calls the nextItem function, it will not immediately
16 | * result in a call to cb -- the stack will unwind to the asyncLoop call
17 | * before continuing.
18 | */
19 |
20 | import std.js as JS;
21 |
22 | exports = Class(function() {
23 | this.init = function(src) {
24 | this._src = src;
25 | this._i = 0;
26 |
27 | // a call count prevents a stack overflow if the callback in
28 | // an aysncloop is called repeatedly for large arrays
29 | this._calls = 0;
30 | if (JS.isArray(src)) {
31 | this._isArray = true;
32 | } else if (Object.keys) {
33 | this._keys = Object.keys(src);
34 | } else {
35 | var k = this._keys = [];
36 | for (var i in src) { if (src.hasOwnProperty(i)) { k.push(i); } }
37 | }
38 | }
39 |
40 | this.nextKey = function() {
41 | return this._keys[this._i++];
42 | }
43 |
44 | this.next = function() {
45 | if (this._isArray) {
46 | return this._src[this._i++] || exports.END_OF_LOOP;
47 | } else {
48 | var key = this._keys[this._i++];
49 | return key ? this._src[key] : exports.END_OF_LOOP;
50 | }
51 | }
52 |
53 | this.loop = function(cb) {
54 | if (arguments.length > 1) { cb = bind.apply(this, arguments); }
55 | var next;
56 | if (this._isArray) {
57 | while((next = this.next())) {
58 | cb(next);
59 | }
60 | } else {
61 | while((next = this.nextKey())) {
62 | cb(this._src[next], next);
63 | }
64 | }
65 | }
66 |
67 | this.asyncLoop = function(cb) {
68 | if (arguments.length > 1) { cb = bind.apply(this, arguments); }
69 | this._next = bind(this, '_onReturn', cb);
70 | this._calls++;
71 | this._asyncLoop(cb);
72 | }
73 |
74 | this._asyncLoop = function(cb) {
75 | this._inLoop = true;
76 | while (this._calls) {
77 | --this._calls;
78 | cb(this.next(), this._next);
79 | }
80 | this._inLoop = false;
81 | }
82 |
83 | this._onReturn = function(cb) {
84 | this._calls++;
85 | if (!this._inLoop) { this._asyncLoop(cb); }
86 | }
87 | });
88 |
89 | exports.END_OF_LOOP = new Error('jsio.Iterator.END_OF_LOOP');
90 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/LogClass.js:
--------------------------------------------------------------------------------
1 | exports = function(name, parent, proto) {
2 | if (!proto) { proto = parent; parent = null; }
3 | var protoRef = {},
4 | loggingProto = bind(this, LogClassProto, name, proto, logging.get(name), protoRef);
5 | protoRef.proto = loggingProto;
6 | return parent ? Class(parent, loggingProto) : Class(loggingProto);
7 | }
8 |
9 | function LogClassProto(name, proto, logger, protoRef, supr) {
10 | proto.prototype = protoRef.proto.prototype;
11 | var p = new proto(logger, supr);
12 | p.__class__ = name;
13 | return p;
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/PubSub.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Summary: inherit from lib.PubSub if a class wants publish/subscribe ability
3 | * Methods:
4 | * - publish(signal, args...) - all subscribers to signal will be called
5 | * with the list of arguments provided.
6 | * - subscribe(signal, ctx, method, args...) - register a bound method
7 | * to a signal. Any args that are passed in will be the first args
8 | * when the method is invoked during a publish.
9 | * Usage notes: There is one special signal '__any'. Any subscribers to
10 | * '__any' will be called on every publish with the first publish
11 | * argument being the signal itself (after any args passed in during
12 | * the corresponding subscribe).
13 | * Calling the super constructor is not required for descendants of
14 | * lib.PubSub.
15 | */
16 | var ctx = jsio.__env.global;
17 |
18 | exports = Class(function() {
19 | this.init = function() {}
20 |
21 | this.publish = function(signal) {
22 | if(this._subscribers) {
23 | var args = Array.prototype.slice.call(arguments, 1);
24 | if(this._subscribers.__any) {
25 | var anyArgs = [signal].concat(args),
26 | subs = this._subscribers.__any.slice(0);
27 | for(var i = 0, sub; sub = subs[i]; ++i) {
28 | sub.apply(ctx, anyArgs);
29 | }
30 | }
31 |
32 | if(!this._subscribers[signal]) { return; }
33 |
34 | var subs = this._subscribers[signal].slice(0);
35 | for(var i = 0, sub; sub = subs[i]; ++i) {
36 | sub.apply(ctx, args);
37 | }
38 | }
39 | return this;
40 | }
41 |
42 | this.subscribe = function(signal, ctx, method) {
43 | if(!this._subscribers) { this._subscribers = {}; }
44 | if(!this._subscribers[signal]) { this._subscribers[signal] = []; }
45 | var cb = bind.apply(ctx, Array.prototype.slice.call(arguments, 1));
46 | cb._ctx = ctx; // references for unsubscription
47 | cb._method = method;
48 | this._subscribers[signal].push(cb);
49 | return this;
50 | }
51 |
52 | // if no method is specified, all subscriptions with a callback context of ctx will be removed
53 | this.unsubscribe = function(signal, ctx, method) {
54 | if (!this._subscribers || !this._subscribers[signal]) { return; }
55 | var subs = this._subscribers[signal];
56 | for (var i = 0, c; c = subs[i]; ++i) {
57 | if (c._ctx == ctx && (!method || c._method == method)) {
58 | subs.splice(i--, 1);
59 | }
60 | }
61 | return this;
62 | }
63 | });
64 |
65 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/lib/Sortable.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import .LogClass;
4 |
5 | exports = LogClass('lib.Sortable', function(logger) {
6 |
7 | this.toStringPush = function(indexer) {
8 | if (!this._toString || !this._toString.push) {
9 | this._toString = [this.toString];
10 | } else {
11 | this._toString.push(this.toString);
12 | }
13 |
14 | this.toString = indexer;
15 | }
16 |
17 | this.toStringPop = function() {
18 | this.toString = this._toString.pop();
19 | }
20 | });
21 |
22 | var zeroPadding = [];
23 | function ensurePadding(n) {
24 | for (var i = zeroPadding.length; i < n; ++i) {
25 | var str = [];
26 | for (var j = 0; j < i; ++j) { str.push('0'); }
27 | zeroPadding[i] = str.join('');
28 | }
29 | }
30 |
31 | /**
32 | * Here we handle arbitrary sorting indexes transparently converting numbers to strings
33 | * for efficient sorting with toString. Unfortunately, this does not work for large floating
34 | * point values, but that functionality could theoretically be added if desired.
35 | */
36 | function sortIndex(i) { return this[i]; }
37 |
38 | exports.sort = function(arr, indexer) {
39 |
40 | var len = arr.length,
41 | index = new Array(len),
42 | result = new Array(len),
43 | toString = new Array(len),
44 | indexers = Array.prototype.slice.call(arguments, 1),
45 | haveMultiple = !!indexers[1];
46 |
47 | if (haveMultiple) {
48 | for (var i = 0; i < len; ++i) {
49 | result[i] = [];
50 | }
51 | }
52 |
53 | for (var k = 0, indexer; indexer = indexers[k]; ++k) {
54 | for (var i = 0; i < len; ++i) {
55 | index[i] = indexer.call(arr[i], i);
56 | }
57 |
58 | if (typeof index[0] == 'number') {
59 | // we do two passes here:
60 | // 1: find the max and min numerical indices
61 | // 2: convert the indices to strings with appropriate zero-padding
62 | var largest = index[0],
63 | smallest = index[0];
64 |
65 | for (var i = 1; i < len; ++i) {
66 | if (index[i] > largest) {
67 | largest = index[i];
68 | } else if (index[i] < smallest) {
69 | smallest = index[i];
70 | }
71 | }
72 |
73 | // we have to be very careful here - large floating point numbers will break the
74 | // string padding code
75 | var paddingPositive = String(Math.floor(largest)).length,
76 | paddingNegative = String(Math.floor(smallest)).length;
77 |
78 | ensurePadding(Math.max(paddingPositive, paddingNegative));
79 |
80 | var strLen;
81 | for (var i = 0; i < len; ++i) {
82 | var val = index[i];
83 | if (val < 0) {
84 | val = -(smallest - val);
85 | strLen = ('' + Math.floor(val)).length;
86 | index[i] = '-' + zeroPadding[paddingNegative - strLen] + val;
87 | } else {
88 | strLen = ('' + Math.floor(val)).length;
89 | index[i] = zeroPadding[paddingPositive - strLen] + val;
90 | }
91 | }
92 | }
93 |
94 | if (haveMultiple) {
95 | for (var i = 0; i < len; ++i) {
96 | result[i].push(index[i]);
97 | }
98 | } else {
99 | result = index;
100 | }
101 | }
102 |
103 | for (var i = 0; i < len; ++i) {
104 | if (haveMultiple) {
105 | result[i] = result[i].join('|');
106 | }
107 |
108 | toString[i] = arr[i].toString;
109 | arr[i].toString = bind(result, sortIndex, i);
110 | }
111 |
112 | Array.prototype.sort.apply(arr);
113 |
114 | for (var i = 0; i < len; ++i) {
115 | arr[i].toString = toString[i];
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/logging.js:
--------------------------------------------------------------------------------
1 | exports.UIWatcher = Class(function() {
2 |
3 | });
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math/arrays.js:
--------------------------------------------------------------------------------
1 | jsio('import .util');
2 |
3 | exports.weightedAverage = function (a, w, n) {
4 | n = n || a.length;
5 | var s = 0;
6 | for (var i = n - 1; i >= 0; --i) {
7 | s += a[i] * w;
8 | }
9 | return s / n;
10 | }
11 |
12 | exports.subtract = function(a, b) {
13 | var length = a.length,
14 | diff = new Array(length);
15 | for (var i = 0; i < length; ++i) {
16 | diff[i] = b[i] - a[i];
17 | }
18 | return diff;
19 | }
20 |
21 | exports.average = function (a, n) {
22 | n = n || a.length;
23 | var s = 0;
24 | for (var i = n - 1; i >= 0; --i) {
25 | s += a[i];
26 | }
27 | return s / n;
28 | }
29 |
30 | exports.stddev = function (a, n) {
31 | var avg = exports.average(a, n);
32 | n = n || a.length;
33 | var s = 0;
34 | for (var i = n - 1; i >= 0; --i) {
35 | var diff = (a[i] - avg);
36 | s += diff * diff;
37 | }
38 | return Math.sqrt(sum / (1 - n));
39 | }
40 |
41 | exports.shuffle = function(a, randGen) {
42 | var len = a.length;
43 | for (var i = 0; i < len; ++i) {
44 | var j = util.random(i, len, randGen),
45 | temp = a[j];
46 | a[j] = a[i];
47 | a[i] = temp;
48 | }
49 | return a;
50 | }
51 |
52 | exports.rotate = function(a, count) {
53 | var len = a.length,
54 | b = new Array(len),
55 | j = count % len;
56 |
57 | if (j < 0) {
58 | j = j % len;
59 | if (j) { j += len; }
60 | }
61 |
62 | for (var i = 0; i < len; ++i) {
63 | b[i] = a[j];
64 | j = (j + 1) % len;
65 | }
66 |
67 | return b;
68 | }
69 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math/util.js:
--------------------------------------------------------------------------------
1 | jsio('import lib.Enum as Enum');
2 |
3 | exports.interpolate = function(a, b, x) { return a * (1 - x) + b * x; }
4 |
5 | exports.random = function(a, b, rand) { return a + ((rand || Math.random)() * (b - a) | 0); }
6 | exports.rand = Math.random;
7 | exports.int = exports.truncate = function(a) { return a | 0; }
8 |
9 | var round = exports.round = function(a, precision, method) {
10 | if (!method || method == round.ROUND_HALF_AWAY_FROM_ZERO) {
11 | return a.toFixed(precision);
12 | }
13 |
14 | if(!precision) {
15 | if (method == round.ROUND_HALF_UP) { Math.round(a); }
16 |
17 | var int = a | 0,
18 | frac = a - int,
19 | half = frac == 0.5 || frac == -0.5;
20 | if (!half) { return Math.round(a); }
21 |
22 | var sign = a < 0 ? -1 : 1;
23 | switch(method) {
24 | case round.ROUND_HALF_TO_EVEN:
25 | return int % 2 ? int + sign : int;
26 | case round.ROUND_HALF_TO_ODD:
27 | return int % 2 ? int : int + sign;
28 | case round.ROUND_HALF_STOCHASTIC:
29 | return Math.random() < 0.5 ? int + sign : int;
30 | case round.ROUND_HALF_ALTERNATE:
31 | return (round.alt = !round.alt) ? int + sign : int;
32 | }
33 | }
34 |
35 | var int = a | 0,
36 | frac = a - int,
37 | p = Math.pow(10, precision);
38 | return (int + round(frac * p, 0, method) / p).toFixed(precision);
39 | }
40 |
41 | round.alt = true;
42 |
43 | Enum.call(round, 'ROUND_HALF_UP', 'ROUND_HALF_AWAY_FROM_ZERO', 'ROUND_HALF_TO_EVEN', 'ROUND_HALF_STOCHASTIC', 'ROUND_HALF_ALTERNATE');
44 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/Circle.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import .Point;
4 |
5 | exports = Class(Point, function(supr) {
6 | this.init = function(a, b, c) {
7 | switch(arguments.length) {
8 | case 0:
9 | this.x = 0;
10 | this.y = 0;
11 | this.radius = 0;
12 | break;
13 | case 1:
14 | case 2:
15 | this.x = a.x || 0;
16 | this.y = a.y || 0;
17 | this.radius = a.radius || 0;
18 | break;
19 | case 3:
20 | this.x = a;
21 | this.y = b;
22 | this.radius = c;
23 | break;
24 | }
25 | }
26 |
27 | this.scale = function(s) {
28 | supr(this, 'scale', arguments);
29 | this.radius *= s;
30 | return this;
31 | }
32 | });
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/Line.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import .Point;
4 |
5 | exports = Class(function() {
6 | this.init = function(a, b, c, d) {
7 | switch(arguments.length) {
8 | case 0:
9 | this.start = new Point();
10 | this.end = new Point();
11 | break;
12 | case 1:
13 | this.start = new Point(a.start);
14 | this.end = new Point(a.end);
15 | break;
16 | case 2:
17 | this.start = new Point(a);
18 | this.end = new Point(b);
19 | break;
20 | case 3:
21 | this.start = new Point(a);
22 | this.end = new Point(b, c);
23 | break;
24 | case 4:
25 | default:
26 | this.start = new Point(a, b);
27 | this.end = new Point(c, d);
28 | break;
29 | }
30 | }
31 |
32 | this.getMagnitude =
33 | this.getLength = function() {
34 | var dx = this.end.x - this.start.x,
35 | dy = this.end.y - this.start.y;
36 |
37 | return Math.sqrt(dx * dx + dy * dy);
38 | }
39 | });
40 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/Point.js:
--------------------------------------------------------------------------------
1 | var Point = exports = Class(function() {
2 | this.init = function(a, b) {
3 | switch(arguments.length) {
4 | case 0:
5 | this.x = 0;
6 | this.y = 0;
7 | break;
8 | case 1:
9 | this.x = a.x || 0;
10 | this.y = a.y || 0;
11 | break;
12 | case 2:
13 | this.x = a;
14 | this.y = b;
15 | break;
16 | }
17 | }
18 |
19 | this.rotate = function(r) {
20 | var x = this.x,
21 | y = this.y,
22 | cosr = Math.cos(r),
23 | sinr = Math.sin(r);
24 |
25 | this.x = x * cosr - y * sinr;
26 | this.y = x * sinr + y * cosr;
27 |
28 | return this;
29 | }
30 |
31 | this.translate =
32 | this.add = function(x, y) {
33 | if (typeof x == 'number') {
34 | this.x += x;
35 | this.y += y;
36 | } else {
37 | this.x += x.x;
38 | this.y += x.y;
39 | }
40 | return this;
41 | }
42 |
43 | this.subtract = function(x, y) {
44 | if (typeof x == 'number') {
45 | this.x -= x;
46 | this.y -= y;
47 | } else {
48 | this.x -= x.x;
49 | this.y -= x.y;
50 | }
51 | return this;
52 | }
53 |
54 | this.scale = function(s) {
55 | this.x *= s;
56 | this.y *= s;
57 | return this;
58 | }
59 |
60 | this.setMagnitude = function(m) {
61 | var theta = Math.atan2(this.y, this.x);
62 | this.x = m * Math.cos(theta);
63 | this.y = m * Math.sin(theta);
64 | return this;
65 | }
66 |
67 | this.normalize = function() {
68 | var m = this.getMagnitude();
69 | this.x /= m;
70 | this.y /= m;
71 | }
72 |
73 | this.addMagnitude = function(m) { return this.setMagnitude(this.getMagnitude() + m); }
74 | this.getMagnitude = function() { return Math.sqrt(this.x * this.x + this.y * this.y); }
75 | this.getDirection =
76 | this.getAngle = function() { return Math.atan2(this.y, this.x); }
77 |
78 | });
79 |
80 | Point.add = Point.translate = function(a, b, c, d) {
81 | switch(arguments.length) {
82 | case 2: return new Point(a).add(b);
83 | case 3: return new Point(a).add(b, c);
84 | case 4: return new Point(a, b).add(c, d);
85 | }
86 | }
87 |
88 | Point.subtract = function(a, b, c, d) {
89 | switch(arguments.length) {
90 | case 2: return new Point(a).subtract(b);
91 | case 3: return new Point(a).subtract(b, c);
92 | case 4: return new Point(a, b).subtract(c, d);
93 | }
94 | }
95 |
96 | Point.scale = function(a, b, c) {
97 | switch(arguments.length) {
98 | case 2: return new Point(a).scale(b);
99 | case 3: return new Point(a, b).scale(c);
100 | }
101 | }
102 |
103 | Point.setMagnitude = function(a, b, c) {
104 | switch(arguments.length) {
105 | case 2: return new Point(a).setMagnitude(c);
106 | case 3: return new Point(a, b).setMagnitude(c);
107 | }
108 | }
109 |
110 | Point.addMagnitude = function(a, b, c) {
111 | switch(arguments.length) {
112 | case 2: pt = new Point(a); break;
113 | case 3: pt = new Point(a, b); b = c; break;
114 | }
115 |
116 | return pt.addMagnitude(b);
117 | }
118 |
119 | Point.getMagnitude = function(a, b) { return new Point(a, b).getMagnitude(); }
120 |
121 | Point.rotate = function(a, b, c) {
122 | switch(arguments.length) {
123 | case 2: return new Point(a).rotate(b);
124 | case 3: return new Point(a, b).rotate(c);
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/Rect.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import lib.Enum;
4 | import .Point;
5 | import .Line;
6 |
7 | var Rect = exports = Class(function() {
8 | this.init = function(a, b, c, d) {
9 | switch(arguments.length) {
10 | case 0: // init
11 | this.width = this.height = this.x = this.y = 0;
12 | break;
13 | case 1: // copy
14 | this.width = a.width;
15 | this.height = a.height;
16 | this.x = a.x;
17 | this.y = a.y;
18 | break;
19 | case 2: // (x, y), (width, height)
20 | this.x = a.x;
21 | this.y = a.y;
22 | this.width = b.x;
23 | this.height = b.y;
24 | break;
25 | case 3: // (x, y), width, height
26 | this.x = a.x;
27 | this.y = a.y;
28 | this.width = b;
29 | this.height = c;
30 | break;
31 | case 4: // x, y, width, height
32 | this.x = a;
33 | this.y = b;
34 | this.width = c;
35 | this.height = d;
36 | break;
37 | }
38 | }
39 |
40 | this.getCorner = function(i) {
41 | switch(i) {
42 | case CORNERS.TOP_LEFT:
43 | return new Point(this.x, this.y);
44 | case CORNERS.TOP_RIGHT:
45 | return new Point(this.x + this.width, this.y);
46 | case CORNERS.BOTTOM_LEFT:
47 | return new Point(this.x, this.y + this.height);
48 | case CORNERS.BOTTOM_RIGHT:
49 | return new Point(this.x + this.width, this.y + this.height);
50 | }
51 | }
52 |
53 | this.getSide = function(i) {
54 | switch(i) {
55 | case SIDES.TOP:
56 | return new Line(this.getCorner(CORNERS.TOP_LEFT), this.getCorner(CORNERS.TOP_RIGHT));
57 | case SIDES.RIGHT:
58 | return new Line(this.getCorner(CORNERS.TOP_RIGHT), this.getCorner(CORNERS.BOTTOM_RIGHT));
59 | case SIDES.BOTTOM:
60 | return new Line(this.getCorner(CORNERS.BOTTOM_RIGHT), this.getCorner(CORNERS.BOTTOM_LEFT));
61 | case SIDES.LEFT:
62 | return new Line(this.getCorner(CORNERS.BOTTOM_LEFT), this.getCorner(CORNERS.TOP_LEFT));
63 | }
64 | }
65 | });
66 |
67 | var SIDES = Rect.SIDES = lib.Enum('TOP', 'BOTTOM', 'LEFT', 'RIGHT'),
68 | CORNERS = Rect.CORNERS = lib.Enum('TOP_LEFT', 'TOP_RIGHT', 'BOTTOM_RIGHT', 'BOTTOM_LEFT');
69 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/angle.js:
--------------------------------------------------------------------------------
1 | var PI = Math.PI,
2 | TWOPI = Math.PI * 2;
3 |
4 | exports.average = function(a, b, weight) {
5 | if (weight === undefined) { weight = 0.5; }
6 | var r1 = exports.getRange(a, b);
7 | var avg = r1 < PI
8 | ? a + r1 * (1 - weight)
9 | : b + (2 * PI - r1) * weight;
10 |
11 | return avg > PI ? avg - 2 * PI : avg < -PI ? avg + 2 * PI : avg;
12 | }
13 |
14 | // between -PI and PI
15 | exports.normalize = function(a) {
16 |
17 | // TODO: don't use loops
18 | while(a < -PI) { a += PI; }
19 | while(a > PI) { a -= PI; }
20 | return a;
21 | }
22 |
23 | exports.add = function(a, b) {
24 | var sum = a + b;
25 | return sum > PI ? sum - TWOPI : sum < -PI ? sum + TWOPI : sum;
26 | }
27 |
28 | // smaller of two angles a - b, b - a
29 | exports.difference = function(a, b) {
30 | var diff = exports.getRange(a, b);
31 | return diff > PI ? diff - TWOPI : diff;
32 | }
33 |
34 | // angular range from a to b, returns float between [0, 2PI]
35 | exports.getRange = function(a, b) {
36 | var r = b - a;
37 | return r < 0 ? r + TWOPI : r;
38 | }
39 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/intersect.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import .Point;
4 | import .Line;
5 | import .Rect;
6 |
7 | var intersect = exports;
8 |
9 | intersect.rectAndPt = function(rect, pt) { return intersect.ptAndRect(pt, rect); }
10 | intersect.ptAndRect = function(pt, rect) {
11 | var x = pt.x,
12 | y = pt.y;
13 |
14 | return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
15 | }
16 |
17 | intersect.circAndPt = function(circ, pt) { return intersect.ptAndCirc(pt, circ); }
18 | intersect.ptAndCirc = function(pt, circ) {
19 | var dx = pt.x - circ.x,
20 | dy = pt.y - circ.y;
21 | return dx * dx + dy * dy < circ.radius * circ.radius;
22 | }
23 |
24 | intersect.rectAndRect = function(rect1, rect2) {
25 | return !(
26 | (rect1.y + rect1.height < rect2.y)
27 | || (rect2.y + rect2.height < rect1.y)
28 | || (rect1.x + rect1.width < rect2.x)
29 | || (rect2.x + rect2.width < rect1.x)
30 | );
31 | }
32 |
33 | var SIDES = Rect.SIDES;
34 |
35 | intersect.rectAndCircle = function(rect, circle) { return intersect.rectAndCircle(circle, circ); }
36 | intersect.circleAndRect = function(circle, rect) {
37 | if (intersect.ptAndRect(circle, rect)) {
38 | return true;
39 | }
40 |
41 | return intersect.lineAndCircle(rect.getSide(1), circle)
42 | || intersect.lineAndCircle(rect.getSide(2), circle)
43 | || intersect.lineAndCircle(rect.getSide(3), circle)
44 | || intersect.lineAndCircle(rect.getSide(4), circle);
45 | }
46 |
47 | intersect.circleAndLine = function(circle, line) { return intersect.lineAndCircle(line, circle); }
48 | intersect.lineAndCircle = function(line, circle) {
49 | var vec = intersect.util.ptToLine(circle, line);
50 | return vec.getMagnitude() < circle.radius;
51 | }
52 |
53 | // util -- does not return a true/false intersection
54 |
55 | intersect.util = {};
56 |
57 | // returns line from pt to nearest pt on line
58 | intersect.util.ptToLine = function(pt, line) {
59 | var dx = (line.end.x - line.start.x),
60 | dy = (line.end.y - line.start.y),
61 | u = ((pt.x - line.start.x) * dx // TODO can we abstract this from 2D to 2D/3D?
62 | + (pt.y - line.start.y) * dy) /
63 | (dx * dx + dy * dy);
64 |
65 | var i;
66 | if (u < 0) {
67 | i = new Point(line.start);
68 | } else if (u > 1) {
69 | i = new Point(line.end);
70 | } else {
71 | i = new Point(line.start.x + u * dx, line.start.y + u * dy);
72 | }
73 | return new Line(i, pt);
74 | }
75 |
76 | // returns rectangle of intersection
77 | intersect.util.rectAndRect = function(rect1, rect2) {
78 | if (intersect.rectAndRect(rect1, rect2)) {
79 | var x1 = Math.max(rect1.x, rect2.x),
80 | y1 = Math.max(rect1.y, rect2.y),
81 | x2 = Math.min(rect1.x + rect1.width, rect2.x + rect2.width),
82 | y2 = Math.min(rect1.y + rect1.height, rect2.y + rect2.height);
83 | return new Rect(x, y, x2 - x1, y2 - y1);
84 | }
85 | return null;
86 | }
87 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/math2D/morphology.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | exports.open = function(img, mask) {
4 | return exports.dilate(exports.erode(img, mask), mask);
5 | }
6 |
7 | exports.close = function(img, mask) {
8 | return exports.erode(exports.dilate(img, mask), mask);
9 | }
10 |
11 | exports.getSquareMask = function(d) {
12 | if (d % 2 == 0) { d++; }
13 | var mask = [];
14 | for (var x = 0; x < d; ++x) {
15 | mask[x] = [];
16 | for (var y = 0; y < d; ++y) {
17 | mask[x][y] = 1;
18 | }
19 | }
20 | return mask;
21 | }
22 |
23 | exports.getCircleMask = function(d) {
24 | if (d % 2 == 0) { d++; }
25 | var mask = [],
26 | r = d / 2 - 0.5,
27 | c = r;
28 | for (var y = 0; y < d; ++y) {
29 | mask[y] = [];
30 | for (var x = 0; x < d; ++x) {
31 | var dx = x - c, dy = y - c;
32 | mask[y][x] = Math.sqrt(dx * dx + dy * dy) <= r ? 1 : 0;
33 | }
34 | }
35 | return mask;
36 | }
37 |
38 | exports.multiply = function(img1, c) {
39 | var w = img1.width, h = img1.height;
40 | for (var y = 0; y < h; ++y) {
41 | for (var x = 0; x < w; ++x) {
42 | img1[y][x] *= c;
43 | }
44 | }
45 | return img1;
46 | }
47 |
48 | exports.subtract = function(img1, img2) {
49 | var w = Math.min(img1.width, img2.width),
50 | h = Math.min(img1.height, img2.height);
51 |
52 | for (var y = 0; y < h; ++y) {
53 | for (var x = 0; x < w; ++x) {
54 | img1[y][x] -= img2[y][x];
55 | }
56 | }
57 | return img1;
58 | }
59 |
60 | exports.erode = function(img, mask) {
61 | logger.info('erode');
62 |
63 | var lmx = (mask.length - 1) / 2,
64 | lmy = (mask[0].length - 1) / 2,
65 | out = [],
66 | w = img.width,
67 | h = img.height;
68 |
69 | out.width = w;
70 | out.height = h;
71 |
72 | for (var y = 0; y < h; ++y) {
73 | out[y] = [];
74 | for (var x = 0; x < w; ++x) {
75 | var count = true;
76 | for (var mx = -lmx; mx < lmx + 1; ++mx) {
77 | for (var my = -lmy; my < lmy + 1; ++my) {
78 | var sx = x + mx, sy = y + my;
79 | mask[my + lmy][mx + lmx]
80 | && (count &= sx >= 0 && sx < w && sy >= 0 && sy < h && img[sy][sx]);
81 | }
82 | }
83 | out[y][x] = count && 255;
84 | }
85 | }
86 | return out;
87 | }
88 |
89 | exports.dilate = function (img, mask) {
90 | logger.info('dilate');
91 |
92 | var lmx = (mask.length - 1) / 2,
93 | lmy = (mask[0].length - 1) / 2,
94 | out = [],
95 | w = img.width,
96 | h = img.height;
97 |
98 | out.width = w;
99 | out.height = h;
100 |
101 | for (var y = 0; y < h; ++y) {
102 | out[y] = [];
103 | for (var x = 0; x < w; ++x) {
104 | var count = false;
105 | for (var mx = -lmx; mx < lmx + 1; ++mx) {
106 | for (var my = -lmy; my < lmy + 1; ++my) {
107 | var sx = x + mx, sy = y + my;
108 | count |= sx >= 0 && sx < w && sy >= 0 && sy < h
109 | && mask[my + lmy][mx + lmx] && img[sy][sx];
110 | }
111 | }
112 | out[y][x] = count && 255;
113 | }
114 | }
115 | return out;
116 | }
117 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net.js:
--------------------------------------------------------------------------------
1 | jsio('import net.env');
2 | jsio('import std.JSON as JSON');
3 |
4 | JSON.createGlobal(); // create the global JSON object if it doesn't already exist
5 |
6 | exports.listen = function(server, transportName, opts) {
7 | if (!transportName) {
8 | throw logger.error('No transport provided for net.listen');
9 | }
10 | var listenerClass = net.env.getListener(transportName);
11 | var listener = new listenerClass(server, opts);
12 | listener.listen();
13 | return listener;
14 | }
15 |
16 | exports.connect = function(protocolInstance, transportName, opts) {
17 | var ctor = typeof transportName == 'string' ? net.env.getConnector(transportName) : transportName,
18 | connector = new ctor(protocolInstance, opts);
19 |
20 | connector.connect();
21 | return connector;
22 | }
23 |
24 | exports.quickServer = function(protocolClass) {
25 | jsio('import net.interfaces');
26 | return new net.interfaces.Server(protocolClass);
27 | }
28 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/buffer.js:
--------------------------------------------------------------------------------
1 | jsio('from net.interfaces import Protocol');
2 |
3 | var EmptyBufferError = exports.EmptyBufferError = Class(function () {
4 | this.init = function(message) { this.message = message; }
5 | })
6 |
7 | exports.Buffer = Class(function(supr) {
8 |
9 | this.init = function(rawBuffer) {
10 |
11 | this._rawBuffer = !!rawBuffer ? rawBuffer : "";
12 | }
13 |
14 | this.getLength = function() {
15 | return this._rawBuffer.length;
16 | }
17 |
18 | this.append = function(data) {
19 | logger.debug('append', JSON.stringify(data));
20 | this._rawBuffer += data;
21 | }
22 |
23 | this.peekBytes = function(num) {
24 | if (!!num)
25 | return this._rawBuffer.slice(0, num);
26 | else
27 | return this._rawBuffer;
28 | }
29 |
30 | this.peekToDelimiter = function(delimiter) {
31 | delimiter = delimiter ? delimiter : '\n';
32 | var i = this._rawBuffer.indexOf(delimiter);
33 | if (i == -1)
34 | throw new EmptyBufferError("delimiter " + delimiter + "not present in buffer");
35 | else
36 | return this._rawBuffer.slice(0, i);
37 | }
38 |
39 | this.consumeBytes = function(num) {
40 | var output = this.peekBytes(num);
41 | this._rawBuffer = this._rawBuffer.slice(output.length);
42 | return output;
43 | }
44 | this.consumeMaxBytes = function(num) {
45 | var output = this._rawBuffer.slice(0, num);
46 | this._rawBuffer = this._rawBuffer(num);
47 | return output;
48 | }
49 | this.consumeAllBytes = function() {
50 | var temp = this._rawBuffer;
51 | this._rawBuffer = "";
52 | return temp;
53 | }
54 |
55 | this.consumeThroughDelimiter = function(delimiter) {
56 | return this.consumeToDelimiter(delimiter) + this.consumeBytes(delimiter.length);
57 | }
58 |
59 | this.consumeToDelimiter = function(delimiter) {
60 | delimiter = !!delimiter ? delimiter : "\n"
61 | var output = this.peekToDelimiter(delimiter);
62 | this._rawBuffer = this._rawBuffer.slice(output.length);
63 | return output;
64 | }
65 |
66 | this.hasBytes = function(num) {
67 | num = num ? num : 0;
68 | return this._rawBuffer.length >= num;
69 | }
70 |
71 | this.hasDelimiter = function(delimiter) {
72 | delimiter = !!delimiter ? delimiter : '\n';
73 | return (this._rawBuffer.indexOf(delimiter) != -1);
74 | }
75 |
76 | })
77 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env.js:
--------------------------------------------------------------------------------
1 | function getObj(objectName, transportName, envName) {
2 |
3 | try {
4 | var DYNAMIC_IMPORT_ENV = 'from .env.' + (envName || jsio.__env.name) + '.' + transportName + ' import ' + objectName + ' as result';
5 | jsio(DYNAMIC_IMPORT_ENV);
6 | } catch(e) {
7 | throw logger.error('Invalid transport (', transportName, ') or environment (', envName, ')');
8 | }
9 | return result;
10 | }
11 |
12 | exports.getListener = bind(this, getObj, 'Listener');
13 | exports.getConnector = bind(this, getObj, 'Connector');
14 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/browser/csp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from net.csp.client import CometSession');
3 | jsio('import std.utf8 as utf8');
4 |
5 | exports.Connector = Class(net.interfaces.Connector, function() {
6 | this.connect = function() {
7 | this._state = net.interfaces.STATE.CONNECTING;
8 |
9 | var conn = new CometSession();
10 | conn.onconnect = bind(this, 'cometSessionOnConnect', conn);
11 | conn.ondisconnect = bind(this, 'onDisconnect');
12 |
13 | logger.debug('opening the connection');
14 | if (!this._opts.encoding) { this._opts.encoding = 'plain'; }
15 | var url = this._opts.url;
16 | delete this._opts.url;
17 | conn.connect(url, this._opts);//{encoding: 'plain'});
18 | }
19 |
20 | this.cometSessionOnConnect = function(conn) {
21 | logger.debug('conn has opened');
22 | this.onConnect(new Transport(conn));
23 | }
24 | });
25 |
26 | var Transport = Class(net.interfaces.Transport, function() {
27 | this.init = function(conn) {
28 | this._conn = conn;
29 | }
30 |
31 | this.makeConnection = function(protocol) {
32 | this._conn.onread = bind(protocol, 'dataReceived');
33 | }
34 |
35 | this.write = function(data) {
36 | this._conn.write(data);
37 | }
38 |
39 | this.loseConnection = function(protocol) {
40 | this._conn.close();
41 | }
42 | });
43 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/browser/networkConsole.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
28 |
36 |
37 |
38 |
42 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/browser/postmessage.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from util.browser import $');
3 |
4 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
5 | var ID = 0;
6 |
7 | this.init = function() {
8 | supr(this, 'init', arguments);
9 | this._clients = {};
10 | if (!this._opts.clientUrl) {
11 | this._opts.clientUrl = jsio.__dir + '/networkConsole.html';
12 | }
13 | }
14 |
15 | this.listen = function() {
16 | $.onEvent(window, 'message', bind(this, '_onMessage'));
17 | }
18 |
19 | this.getButton = function(url, text) {
20 | var button = $({
21 | tagName: 'button',
22 | text: text || 'launch client',
23 | className: 'clientButton'
24 | });
25 | $.onEvent(button, 'click', bind(this, 'openWindow', url || this._opts.clientUrl));
26 | return button;
27 | }
28 |
29 | var uniqueId = 1;
30 | this.openWindow = function(url) {
31 | var options = { menubar: 'no', location: 'no', toolbar: 'no',
32 | width: 550, height: 350, // left: 200, top: 200,
33 | scrollbars: 'yes', status: 'yes', resizable: 'yes' };
34 |
35 | var arr = [];
36 | for (var i in options) { arr.push(i + '=' + options[i]) }
37 | var win = window.open(url, 'W' + uniqueId++, arr.join(','));
38 | win.focus();
39 | }
40 |
41 | this._onMessage = function(evt) {
42 | var name = evt.source.name;
43 | var target = this._clients[name];
44 | var data = eval('(' + evt.data + ')');
45 | switch (data.type) {
46 | case 'open':
47 | this._clients[name] = new exports.Transport(evt.source);
48 | evt.source.postMessage('{type:"open"}','*');
49 | this.onConnect(this._clients[name]);
50 | break;
51 | case 'data':
52 | target.onData(data.payload);
53 | break;
54 | case 'close':
55 | target.onClose();
56 | evt.source.postMessage('{type:"close"}','*');
57 | delete this._clients[name];
58 | break;
59 | }
60 | }
61 | });
62 |
63 | exports.Connector = Class(net.interfaces.Connector, function() {
64 | this.connect = function() {
65 | $.onEvent(window, 'message', bind(this, '_onMessage'));
66 | window.opener.postMessage(JSON.stringify({type:"open"}), '*');
67 | }
68 |
69 | this._onMessage = function(evt) {
70 | var data = eval('(' + evt.data + ')');
71 | switch(data.type) {
72 | case 'open':
73 | this._transport = new exports.Transport(evt.source);
74 | this.onConnect(this._transport);
75 | break;
76 | case 'close':
77 | this._transport.onClose();
78 | break;
79 | case 'data':
80 | this._transport.onData(data.payload);
81 | break;
82 | }
83 | }
84 | });
85 |
86 | exports.Transport = Class(net.interfaces.Transport, function() {
87 | this.init = function(win) {
88 | this._win = win;
89 | }
90 |
91 | this.makeConnection = function(protocol) {
92 | this._protocol = protocol;
93 | }
94 |
95 | this.write = function(data, encoding) {
96 | if (this.encoding == 'utf8') {
97 | this._win.postMessage(JSON.stringify({type: 'data', payload: utf8.encode(data)}), '*');
98 | } else {
99 | this._win.postMessage(JSON.stringify({type: 'data', payload: data}), '*');
100 | }
101 | }
102 |
103 | this.loseConnection = function(protocol) {
104 | this._win.postMessage(JSON.stringify({type: 'close', code: 301}), '*');
105 | }
106 |
107 | this.onData = function() { this._protocol.dataReceived.apply(this._protocol, arguments); }
108 | this.onClose = function() { this._protocol.connectionLost.apply(this._protocol, arguments); }
109 | });
110 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/browser/websocket.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('import std.utf8 as utf8');
3 | jsio('import net.errors as Errors');
4 |
5 | exports.Connector = Class(net.interfaces.Connector, function() {
6 | this.connect = function() {
7 | this._state = net.interfaces.STATE.CONNECTING;
8 |
9 | var url = this._opts.url,
10 | ctor = this._opts.wsConstructor || window.WebSocket;
11 |
12 | logger.info('this._opts', this._opts);
13 |
14 | var ws = new ctor(url);
15 | ws.onopen = bind(this, 'webSocketOnOpen', ws);
16 | ws.onclose = bind(this, 'webSocketOnClose', ws);
17 | }
18 |
19 | this.webSocketOnOpen = function(ws) {
20 | this.onConnect(new Transport(ws));
21 | }
22 |
23 | this.webSocketOnClose = function(ws, e) {
24 | var err,
25 | data = {rawError: e, webSocket: ws};
26 | if (e.wasClean) {
27 | err = new Errors.ServerClosedConnection('WebSocket Connection Closed', data);
28 | } else {
29 | if (this._state == net.interfaces.STATE.CONNECTED) {
30 | err = new Errors.ConnectionTimeout('WebSocket Connection Timed Out', data);
31 | } else {
32 | err = new Errors.ServerUnreachable('WebSocket Connection Failed', data);
33 | }
34 | }
35 |
36 | logger.debug('conn closed', err);
37 | this.onDisconnect(err);
38 | }
39 | });
40 |
41 | var Transport = Class(net.interfaces.Transport, function() {
42 |
43 | this.init = function(ws) {
44 | this._ws = ws;
45 | }
46 |
47 | this.makeConnection = function(protocol) {
48 | this._ws.onmessage = function(data) {
49 | var payload = utf8.encode(data.data);
50 | protocol.dataReceived(payload);
51 | }
52 | }
53 |
54 | this.write = function(data, encoding) {
55 | if (this._encoding == 'plain') {
56 | result = utf8.decode(data);
57 | data = result[0];
58 | }
59 | this._ws.send(data);
60 | }
61 |
62 | this.loseConnection = function(protocol) {
63 | this._ws.close();
64 | }
65 | });
66 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/node/csp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from .csp.server import createServer');
3 |
4 | var Transport = Class(net.interfaces.Transport, function() {
5 | this.init = function(socket) {
6 | this._socket = socket;
7 | logger.debug('init', socket);
8 | }
9 |
10 | this.makeConnection = function(protocol) {
11 | logger.debug('makeConnection:', protocol);
12 | this._socket.addListener("receive", bind(protocol, 'dataReceived'));
13 |
14 | this._socket.addListener("eof", this._socket.close);
15 | this._socket.addListener("close", bind(protocol, 'connectionLost')); // TODO: map error codes
16 | }
17 |
18 | this.write = function(data) {
19 | this._socket.send(data);
20 | }
21 |
22 | this.loseConnection = function() {
23 | this._socket.forceClose();
24 | }
25 | });
26 |
27 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
28 | this.listen = function() {
29 | var s = createServer(bind(this, function(socket) {
30 | logger.info("Incoming connection");
31 | socket.setEncoding("utf8");
32 | socket.addListener("connect", bind(this, function() {
33 | this.onConnect(new Transport(socket));
34 | }));
35 | }));
36 | this._cspServer = s;
37 | var listenString = (this._opts.interface || "" ) + ":" + this._opts.port;
38 | // TODO: Show class name
39 | if (!this._opts.skipListen) {
40 | logger.info("Listening csp@" + listenString);
41 | s.listen(this._opts.port, this._opts.interface || "");
42 | }
43 | }
44 | });
45 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/node/csp/util.js:
--------------------------------------------------------------------------------
1 | /*
2 | Helper functions, &c., for a comet server by Jacob Rus.
3 |
4 | --------------------
5 |
6 | Copyright (c) 2009 Jacob Rus
7 |
8 | Permission is hereby granted, free of charge, to any person
9 | obtaining a copy of this software and associated documentation
10 | files (the "Software"), to deal in the Software without
11 | restriction, including without limitation the rights to use,
12 | copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the
14 | Software is furnished to do so, subject to the following
15 | conditions:
16 |
17 | The above copyright notice and this permission notice shall be
18 | included in all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 | OTHER DEALINGS IN THE SOFTWARE.
28 | */
29 |
30 | // helper to test if string 2 is at the beginning of string 1
31 | exports.startswith = function (str1, str2) {
32 | return str1.substring(0, str2.length) == str2;
33 | };
34 |
35 | exports.JSIOError = Class(Error, function () {
36 | this.name = 'JSIOError';
37 | this.toString = Error.prototype.toString;
38 | this.init = function (message, fileName, lineNumber) {
39 | this.name = this.name; // promote class property to instance
40 | this.message = message || '';
41 | this.fileName = fileName || '«filename»'; // location.href; // XXX what should go here?
42 | this.lineNumber = isNaN(+lineNumber) ? 0 : +lineNumber
43 | };
44 | });
45 |
46 | exports.AssertionError = Class(exports.JSIOError, function (supr) {
47 | this.name = 'AssertionError'
48 | this.init = function () {supr(this, 'init', arguments)}
49 | });
50 |
51 | exports.assert = function (exp, message) {
52 | if (!exp) {
53 | throw new exports.AssertionError(message)
54 | };
55 | };
56 |
57 | // schedule a callback to run at the next available moment,
58 | // equivalent to setTimeout(callback, 0)
59 | exports.reschedule = function (callback) {
60 | return $setTimeout(callback, 0);
61 | };
62 |
63 | // cached static files
64 | exports.staticFile = (function(){
65 | var cache = {} // static file content indexed by filename
66 | var getfile = function(path, callback) {
67 | cacheContent = cache[path];
68 | if (cacheContent !== undefined) {
69 | // the file is in the cache, return it
70 | exports.reschedule(function(){
71 | callback(null, [cacheContent]);
72 | });
73 | } else {
74 | // load file from disk, save it in the cache, and return it
75 | process.fs.readFile(path, 'utf8', function(err, fileContent){
76 | if (err) {
77 | callback('staticFile readFile error ' + err)
78 | } else {
79 | cache[path] = fileContent;
80 | callback(null, [fileContent]);
81 | }
82 | })
83 | };
84 | return promise;
85 | };
86 | return getfile;
87 | })();
88 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/node/stdio.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | var Transport = Class(net.interfaces.Transport, function(supr) {
4 | this.init = function(inStream, outStream) {
5 | this._inStream = inStream;
6 | this._outStream = outStream;
7 | this.setEncoding('plain')
8 | }
9 |
10 | this.setEncoding = function(encoding) {
11 | supr(this, 'setEncoding', arguments);
12 | if (encoding == 'plain') {
13 | encoding = 'binary';
14 | }
15 | this._inStream.setEncoding(encoding);
16 | this._outStream.setEncoding(encoding);
17 | }
18 |
19 | this.makeConnection = function(protocol) {
20 | this._inStream.on('data', bind(protocol, 'dataReceived'));
21 | }
22 |
23 |
24 | this.write = function(data) {
25 | this._outStream.write(data);
26 | this._outStream.flush();
27 | }
28 |
29 | this.loseConnection = function() {
30 | }
31 | });
32 |
33 |
34 | exports.Connector = Class(net.interfaces.Connector, function() {
35 | this.connect = function() {
36 | var stdin = process.openStdin();
37 | var stdout = process.stdout
38 | var transport = new Transport(stdin, stdout)
39 | this.onConnect(transport);
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/env/node/tcp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | var nodeTcp = jsio.__env.require('net');
4 |
5 | var Transport = Class(net.interfaces.Transport, function() {
6 | this.init = function(socket) {
7 | this._socket = socket;
8 | }
9 |
10 | this.makeConnection = function(protocol) {
11 | this._socket.addListener("data", bind(protocol, 'dataReceived'));
12 | this._socket.addListener("close", bind(protocol, 'connectionLost')); // TODO: map error codes
13 | this._socket.addListener("end", this._socket.close);
14 | }
15 |
16 | this.write = function(data) {
17 | this._socket.write(data);
18 | }
19 |
20 | this.loseConnection = function() {
21 | this._socket.forceClose();
22 | }
23 | });
24 |
25 |
26 | exports.Connector = Class(net.interfaces.Connector, function() {
27 | this.connect = function() {
28 |
29 | var conn = nodeTcp.createConnection(this._opts.port, this._opts.host);
30 | conn.addListener("connect", bind(this, function() {
31 | this.onConnect(new Transport(conn));
32 | }))
33 | // conn.addListener("close", bind(this, function() {
34 | // this.onDisconnect();
35 | // }))
36 | // conn.addListener("receive", bind(this._protocol, 'dataReceived'));
37 | this._opts.encoding = 'plain';
38 | conn.setEncoding("binary");
39 | if (typeof this._opts.timeout == 'number') { conn.setTimeout(this._opts.timeout); }
40 | }
41 | });
42 |
43 | exports.Listener = Class(net.interfaces.Listener, function(supr) {
44 | this.listen = function() {
45 | var s = nodeTcp.createServer(bind(this, function(socket) {
46 | if (typeof this._opts.timeout == 'number') { socket.setTimeout(this._opts.timeout) }
47 | socket.setEncoding("utf8");
48 | socket.addListener("connect", bind(this, function() {
49 | this.onConnect(new Transport(socket));
50 | }));
51 | }));
52 | var listenString = (this._opts.interface || "" ) + ":" + this._opts.port;
53 | // TODO: Show class name
54 | logger.info("Listening tcp@" + listenString);
55 | s.listen(this._opts.port, this._opts.interface || "");
56 | }
57 | });
58 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/errors.js:
--------------------------------------------------------------------------------
1 | var makeErrorClass = function(name, _code) {
2 | var toString = function() {
3 | return name + (this.message ? ': ' + this.message : '');
4 | }
5 |
6 | var ctor = function(data) {
7 | if (typeof data == 'string') {
8 | this.message = data;
9 | } else {
10 | this.data = data;
11 | }
12 | }
13 |
14 | ctor.prototype = {
15 | type: name,
16 | toString: toString
17 | };
18 |
19 | return ctor;
20 | }
21 |
22 | exports.ReadyStateError = makeErrorClass("ReadyStateError");
23 | exports.InvalidEncodingError = makeErrorClass("InvalidEncodingError");
24 | exports.ExpiredSession = makeErrorClass("ExpiredSession");
25 |
26 | exports.ServerUnreachable = makeErrorClass("ServerUnreachable", 100);
27 | exports.ConnectionTimeout = makeErrorClass("ConnectionTimeout", 101);
28 |
29 | exports.ServerProtocolError = makeErrorClass("ServerProtocolError", 200);
30 |
31 | exports.ServerClosedConnection = makeErrorClass("ServerClosedConnection", 301);
32 | exports.ConnectionClosedCleanly = makeErrorClass("ConnectionClosedCleanly", 300);
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/interfaces.js:
--------------------------------------------------------------------------------
1 | // Sort of like a twisted protocol
2 | jsio('import net');
3 | jsio('import lib.Enum as Enum');
4 |
5 | var ctx = jsio.__env.global;
6 |
7 | exports.Protocol = Class(function() {
8 | this.connectionMade = function(isReconnect) {}
9 | this.dataReceived = function(data) {}
10 | this.connectionLost = function(reason) {}
11 | });
12 |
13 | exports.Client = Class(function() {
14 | this.init = function(protocol) {
15 | this._protocol = protocol;
16 | }
17 |
18 | this.connect = function(transportName, opts) {
19 | this._remote = new this._protocol();
20 | this._remote._client = this;
21 | net.connect(this._remote, transportName, opts);
22 | }
23 | });
24 |
25 | // Sort of like a twisted factory
26 | exports.Server = Class(function() {
27 | this.init = function(protocolClass) {
28 | this._protocolClass = protocolClass;
29 | }
30 |
31 | this.buildProtocol = function() {
32 | return new this._protocolClass();
33 | }
34 |
35 | this.listen = function(how, port) {
36 | return net.listen(this, how, port);
37 | }
38 | });
39 |
40 | exports.Transport = Class(function() {
41 | this._encoding = 'plain'
42 | this.write = function(data, encoding) {
43 | throw new Error("Not implemented");
44 | }
45 | this.getPeer = function() {
46 | throw new Error("Not implemented");
47 | }
48 | this.setEncoding = function(encoding) {
49 | this._encoding = encoding;
50 | }
51 | this.getEncoding = function() {
52 | return this._encoding;
53 | }
54 | });
55 |
56 | exports.Listener = Class(function() {
57 | this.init = function(server, opts) {
58 | this._server = server;
59 | this._opts = opts || {};
60 | }
61 |
62 | this.onConnect = function(transport) {
63 | // try {
64 | var p = this._server.buildProtocol();
65 | p.transport = transport;
66 | p.server = this._server;
67 | transport.protocol = p;
68 | transport.makeConnection(p);
69 | p.connectionMade();
70 | // } catch(e) {
71 | // logger.error(e);
72 | // }
73 | }
74 |
75 | this.listen = function() { throw new Error('Abstract class'); }
76 | this.stop = function() {}
77 | });
78 |
79 | exports.STATE = Enum('INITIAL', 'DISCONNECTED', 'CONNECTING', 'CONNECTED');
80 | exports.Connector = Class(function() {
81 | this.init = function(protocol, opts) {
82 | this._protocol = protocol;
83 | this._opts = opts;
84 | this._state = exports.STATE.INITIAL;
85 | }
86 |
87 | this.onConnect = function(transport) {
88 | this._state = exports.STATE.CONNECTED;
89 |
90 | transport.makeConnection(this._protocol);
91 | this._protocol.transport = transport;
92 | try {
93 | this._protocol.connectionMade();
94 | } catch(e) {
95 | throw logger.error(e);
96 | }
97 | }
98 |
99 | this.onDisconnect = function(err) {
100 | var wasConnected = this._state == exports.STATE.CONNECTED;
101 | this._state = exports.STATE.DISCONNECTED;
102 |
103 | try {
104 | this._protocol.connectionLost(err, wasConnected);
105 | } catch(e) {
106 | throw logger.error(e);
107 | }
108 | }
109 |
110 | this.getProtocol = function() { return this._protocol; }
111 | });
112 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/later.js:
--------------------------------------------------------------------------------
1 | exports.Later = Class(function() {
2 | this.init = function() {
3 | this.cb = null
4 | this.eb = null
5 | this.values = []
6 | this.errors = []
7 | this.cancelback = null;
8 | }
9 |
10 | this.succeed = function(data) {
11 | this.callback(data);
12 | }
13 |
14 | this.callback = function() {
15 | logger.debug('callback', [].slice.call(arguments, 0));
16 | if (this.cb) {
17 | var result = this.cb.apply(this, arguments);
18 | if (result == false) {
19 | this.cancel();
20 | }
21 | } else {
22 | this.values.push(arguments);
23 | }
24 | }
25 |
26 | this.errback = function() {
27 | logger.debug('eb', [].slice.call(arguments, 0));
28 | if (this.eb) {
29 | this.eb.apply(this, arguments);
30 | }
31 | else {
32 | this.errors.push(arguments);
33 | }
34 | }
35 |
36 | this.cancel = function() {
37 | if (this.cancelback) {
38 | var cb = this.cancelback;
39 | this.cancelback = null;
40 | cb.call(this);
41 | }
42 | }
43 | this.setCallback = function(cb) {
44 | this.cb = cb;
45 | for (var i = 0, v; v=this.values[i]; ++i) {
46 | this.cb.apply(this, v);
47 | }
48 | this.values = [];
49 | return this;
50 | }
51 | this.setErrback = function(eb) {
52 | this.eb = eb;
53 | for (var i = 0, v; e=this.errors[i]; ++i) {
54 | this.eb.apply(this, e);
55 | }
56 | this.errors = [];
57 | return this;
58 | }
59 | this.setCancelback = function(cancelback) {
60 | this.cancelback = cancelback;
61 | return this;
62 | }
63 | })
64 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/protocols/buffered.js:
--------------------------------------------------------------------------------
1 | jsio('from net.interfaces import Protocol');
2 | jsio('from net.buffer import Buffer');
3 |
4 | exports.BufferedProtocol = Class(Protocol, function(supr) {
5 |
6 | this.init = function() {
7 | this.buffer = new Buffer();
8 | }
9 |
10 | // Overwrite this instead of dataReceived in base classes
11 | this.bufferUpdated = function() {}
12 |
13 | this.dataReceived = function(data) {
14 | this.buffer.append(data);
15 | this.bufferUpdated();
16 | }
17 |
18 | })
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/protocols/delimited.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | exports.DelimitedProtocol = Class(net.interfaces.Protocol, function(supr) {
4 |
5 | this.init = function(delimiter) {
6 | if (!delimiter) {
7 | delimiter = '\r\n'
8 | }
9 | this.delimiter = delimiter;
10 | this.buffer = ""
11 | }
12 |
13 | this.connectionMade = function() {
14 | logger.debug('connectionMade');
15 | }
16 |
17 | this.dataReceived = function(data) {
18 | if (!data) { return; }
19 | logger.debug('dataReceived:(' + data.length + ')', data);
20 | logger.debug('last 2:', data.slice(data.length-2));
21 | this.buffer += data;
22 | logger.debug('index', this.buffer.indexOf(this.delimiter));
23 | var i;
24 | while ((i = this.buffer.indexOf(this.delimiter)) != -1) {
25 | var line = this.buffer.slice(0, i);
26 | this.buffer = this.buffer.slice(i + this.delimiter.length);
27 | this.lineReceived(line);
28 | }
29 | }
30 |
31 | this.lineReceived = function(line) {
32 | logger.debug('Not implemented, lineReceived:', line);
33 | }
34 | this.sendLine = function(line) {
35 | logger.debug('WRITE:', line + this.delimiter);
36 | this.transport.write(line + this.delimiter);
37 | }
38 | this.connectionLost = function() {
39 | logger.debug('connectionLost');
40 | }
41 | });
42 |
43 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/protocols/echo.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 |
3 | exports.Protocol = Class(net.interfaces.Protocol, function() {
4 | this.connectionMade = function() {
5 | logger.debug('in connectionMade');
6 | this.transport.write('Welcome')
7 | }
8 |
9 | this.dataReceived = function(data) {
10 | logger.debug('dataReceived:', data);
11 | this.transport.write('Echo: ' + data);
12 | }
13 | this.connectionLost = function() {
14 | logger.debug('conn lost');
15 | }
16 | });
17 |
18 | exports.Server = Class(net.interfaces.Server, function(supr) {
19 | this.init = function() {
20 | supr(this, 'init', [exports.Protocol]);
21 | }
22 | });
23 |
24 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/net/protocols/rtjp.js:
--------------------------------------------------------------------------------
1 | jsio('import net.interfaces');
2 | jsio('from net.protocols.delimited import DelimitedProtocol');
3 |
4 | exports.RTJPProtocol = Class(DelimitedProtocol, function(supr) {
5 | this.init = function() {
6 | var delimiter = '\r\n';
7 | supr(this, 'init', [delimiter]);
8 | this.frameId = 0;
9 | }
10 |
11 | this.connectionMade = function() {
12 | if (this._client && this._client.connectionMade) { this._client.connectionMade(); }
13 | logger.debug("connectionMade");
14 | }
15 |
16 | var error = function(e) {
17 | logger.error(e);
18 | }
19 |
20 | // Inherit and overwrite
21 | this.frameReceived = function(id, name, args) {
22 | }
23 |
24 | // Public
25 | this.sendFrame = function(name, args) {
26 | if (!args) {
27 | args = {}
28 | }
29 | logger.debug('sendFrame', name, args);
30 | this.sendLine(JSON.stringify([++this.frameId, name, args]));
31 | return this.frameId;
32 | }
33 |
34 | this.lineReceived = function(line) {
35 | try {
36 | var frame = JSON.parse(line);
37 | if (frame.length != 3) {
38 | return error.call(this, "Invalid frame length");
39 | }
40 | if (typeof(frame[0]) != "number") {
41 | return error.call(this, "Invalid frame id");
42 | }
43 | if (typeof(frame[1]) != "string") {
44 | return error.call(this, "Invalid frame name");
45 | }
46 | logger.debug("frameReceived:", frame[0], frame[1], frame[2]);
47 | this.frameReceived(frame[0], frame[1], frame[2]);
48 | } catch(e) {
49 | error.call(this, e);
50 | }
51 | }
52 |
53 | this.connectionLost = function() {
54 | logger.debug('conn lost');
55 | }
56 | });
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/preprocessors/import.js:
--------------------------------------------------------------------------------
1 | var importExpr = /^(\s*)(import\s+.*|from\s+.*)$/gm;
2 |
3 | exports = function(path, moduleDef, opts) {
4 | moduleDef.src = moduleDef.src.replace(importExpr, '$1' + 'jsio' + '("$2");');
5 | }
6 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/std/base64.js:
--------------------------------------------------------------------------------
1 | /*
2 | "URL-safe" Base64 Codec, by Jacob Rus
3 |
4 | This library happily strips off as many trailing '=' as are included in the
5 | input to 'decode', and doesn't worry whether its length is an even multiple
6 | of 4. It does not include trailing '=' in its own output. It uses the
7 | 'URL safe' base64 alphabet, where the last two characters are '-' and '_'.
8 |
9 | --------------------
10 |
11 | Copyright (c) 2009 Jacob Rus
12 |
13 | Permission is hereby granted, free of charge, to any person
14 | obtaining a copy of this software and associated documentation
15 | files (the "Software"), to deal in the Software without
16 | restriction, including without limitation the rights to use,
17 | copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the
19 | Software is furnished to do so, subject to the following
20 | conditions:
21 |
22 | The above copyright notice and this permission notice shall be
23 | included in all copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
27 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
29 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
30 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32 | OTHER DEALINGS IN THE SOFTWARE.
33 | */
34 |
35 | var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
36 | var pad = '=';
37 | var padChar = alphabet.charAt(alphabet.length - 1);
38 |
39 | var shorten = function (array, number) {
40 | // remove 'number' characters from the end of 'array', in place (no return)
41 | for (var i = number; i > 0; i--){ array.pop(); };
42 | };
43 |
44 | var decode_map = {};
45 | for (var i=0, n=alphabet.length; i < n; i++) {
46 | decode_map[alphabet.charAt(i)] = i;
47 | };
48 |
49 |
50 | // use this regexp in the decode function to sniff out invalid characters.
51 | var alphabet_inverse = new RegExp('[^' + alphabet.replace('-', '\\-') + ']');
52 |
53 |
54 |
55 | var Base64CodecError = exports.Base64CodecError = function (message) {
56 | this.message = message;
57 | };
58 | Base64CodecError.prototype.toString = function () {
59 | return 'Base64CodecError' + (this.message ? ': ' + this.message : '');
60 | };
61 |
62 | var assertOrBadInput = function (exp, message) {
63 | if (!exp) { throw new Base64CodecError(message) };
64 | };
65 |
66 | exports.encode = function (bytes) {
67 | assertOrBadInput(!(/[^\x00-\xFF]/.test(bytes)), // disallow two-byte chars
68 | 'Input contains out-of-range characters.');
69 | var padding = '\x00\x00\x00'.slice((bytes.length % 3) || 3);
70 | bytes += padding; // pad with null bytes
71 | var out_array = [];
72 | for (var i=0, n=bytes.length; i < n; i+=3) {
73 | var newchars = (
74 | (bytes.charCodeAt(i) << 020) +
75 | (bytes.charCodeAt(i+1) << 010) +
76 | (bytes.charCodeAt(i+2)));
77 | out_array.push(
78 | alphabet.charAt((newchars >> 18) & 077),
79 | alphabet.charAt((newchars >> 12) & 077),
80 | alphabet.charAt((newchars >> 6) & 077),
81 | alphabet.charAt((newchars) & 077));
82 | };
83 | shorten(out_array, padding.length);
84 | return out_array.join('');
85 | };
86 |
87 | exports.decode = function (b64text) {
88 | logger.debug('decode', b64text);
89 | b64text = b64text.replace(/\s/g, '') // kill whitespace
90 | // strip trailing pad characters from input; // XXX maybe some better way?
91 | var i = b64text.length; while (b64text.charAt(--i) === pad) {}; b64text = b64text.slice(0, i + 1);
92 | assertOrBadInput(!alphabet_inverse.test(b64text), 'Input contains out-of-range characters.');
93 | var padding = Array(5 - ((b64text.length % 4) || 4)).join(padChar);
94 | b64text += padding; // pad with last letter of alphabet
95 | var out_array = [];
96 | for (var i=0, n=b64text.length; i < n; i+=4) {
97 | newchars = (
98 | (decode_map[b64text.charAt(i)] << 18) +
99 | (decode_map[b64text.charAt(i+1)] << 12) +
100 | (decode_map[b64text.charAt(i+2)] << 6) +
101 | (decode_map[b64text.charAt(i+3)]));
102 | out_array.push(
103 | (newchars >> 020) & 0xFF,
104 | (newchars >> 010) & 0xFF,
105 | (newchars) & 0xFF);
106 | };
107 | shorten(out_array, padding.length);
108 | var result = String.fromCharCode.apply(String, out_array);
109 | logger.debug('decoded', result);
110 | return result;
111 | };
112 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/std/js.js:
--------------------------------------------------------------------------------
1 | var SLICE = Array.prototype.slice;
2 |
3 | exports.vargs = function(args, n) { return SLICE.call(args, n || 0); }
4 | exports.isArray = function(input) { return Object.prototype.toString.call(input) === '[object Array]'; }
5 |
6 | exports.shallowCopy = function(input) {
7 | if (exports.isArray(input)) {
8 | return input.slice(0);
9 | } else {
10 | var out = {};
11 | for (var key in input) {
12 | if (input.hasOwnProperty(key)) {
13 | out[key] = input[key];
14 | }
15 | }
16 | }
17 |
18 | return out;
19 | }
20 |
21 | exports.merge = function(base, extra) {
22 | base = base || {};
23 |
24 | for (var i = 1, len = arguments.length; i < len; ++i) {
25 | var copyFrom = arguments[i];
26 | for (var key in copyFrom) {
27 | if (copyFrom.hasOwnProperty(key) && !base.hasOwnProperty(key)) {
28 | base[key] = copyFrom[key];
29 | }
30 | }
31 | }
32 |
33 | return base;
34 | }
35 |
36 | exports.curry = function(method /*, VARGS*/) {
37 | var args = SLICE.call(arguments, 1),
38 | f = typeof method == 'string'
39 | ? function() { this[method].apply(ctx, args.concat(SLICE.call(arguments))); }
40 | : function() { method.apply(this, args.concat(SLICE.call(arguments))); }
41 | f.curried = true;
42 | return f;
43 | }
44 |
45 | exports.unbind = function(method /*, VARGS*/) {
46 | var args = SLICE.call(arguments, 1),
47 | f = typeof method == 'string'
48 | ? function(ctx) { ctx[method].apply(ctx, args.concat(SLICE.call(arguments, 1))); }
49 | : function(ctx) { method.apply(ctx, args.concat(SLICE.call(arguments, 1))); }
50 | f.unbound = true;
51 | return f;
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/std/uri.js:
--------------------------------------------------------------------------------
1 | jsio('import std.js as JS');
2 |
3 | var attrs = [
4 | "source",
5 | "protocol",
6 | "authority",
7 | "userInfo",
8 | "user",
9 | "password",
10 | "host",
11 | "port",
12 | "relative",
13 | "path",
14 | "directory",
15 | "file",
16 | "query",
17 | "anchor"
18 | ];
19 |
20 | var URI = exports = Class(function(supr) {
21 | this.init = function(url, isStrict) {
22 | if (url instanceof URI) {
23 | for (var attr in attrs) {
24 | this['_' + attr] = url['_' + attr];
25 | }
26 | return;
27 | }
28 |
29 | this._isStrict = isStrict;
30 |
31 | var uriData = exports.parse(url, isStrict);
32 | for (var attr in uriData) {
33 | this['_' + attr] = uriData[attr];
34 | };
35 | }
36 |
37 | for (var i = 0, attr; attr = attrs[i]; ++i) {
38 | (function(attr) {
39 | var fNameSuffix = attr.charAt(0).toUpperCase() + attr.slice(1);
40 | this['get' + fNameSuffix] = function() {
41 | return this['_' + attr];
42 | };
43 | this['set' + fNameSuffix] = function(val) {
44 | this['_' + attr] = val;
45 | };
46 | }).call(this, attr);
47 | };
48 |
49 | this.query = function(key) { return exports.parseQuery(this._query)[key]; }
50 | this.hash = function(key) { return exports.parseQuery(this._hash)[key]; }
51 |
52 | this.addQuery = function(kvp) {
53 | this._query = exports.buildQuery(JS.merge(kvp, exports.parseQuery(this._query)));
54 | return this;
55 | }
56 |
57 | this.toString = this.render = function(onlyBase) {
58 | // XXX TODO: This is vaguely reasonable, but not complete. fix it...
59 | var a = this._protocol ? this._protocol + "://" : ""
60 | var b = this._host ? this._host + ((this._port || 80) == 80 ? "" : ":" + this._port) : "";
61 |
62 | if (onlyBase) {
63 | return a + b;
64 | }
65 |
66 | var c = this._path;
67 | var d = this._query ? '?' + this._query : '';
68 | var e = this._anchor ? '#' + this._anchor : '';
69 | return a + b + c + d + e;
70 | };
71 | });
72 |
73 | exports.relativeTo = function(url, base) {
74 | url = String(url);
75 |
76 | if (/^http(s?):\/\//.test(url)) { return url; }
77 | if (url.charAt(0) == '/') {
78 | var baseuri = new exports(base);
79 | url = baseuri.toString(true) + url;
80 | } else if(url.charAt(0) == '.') {
81 | url = base + url;
82 | }
83 |
84 | return exports.resolveRelative(url);
85 | }
86 |
87 | exports.resolveRelative = function(url) {
88 | var prevUrl;
89 |
90 | // remove ../ with preceeding folder
91 | while((prevUrl = url) != (url = url.replace(/(^|\/)([^\/]+)\/\.\.\//g, '/'))) {};
92 |
93 | // remove ./ if it isn't preceeded by a .
94 | return url.replace(/[^.]\.\//g, '');
95 | }
96 |
97 | exports.buildQuery = function(kvp) {
98 | var pairs = [];
99 | for (var key in kvp) {
100 | pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(kvp[key]));
101 | }
102 | return pairs.join('&');
103 | }
104 |
105 | exports.parseQuery = function(str) {
106 | var pairs = str.split('&'),
107 | n = pairs.length,
108 | data = {};
109 | for (var i = 0; i < n; ++i) {
110 | var pair = pairs[i].split('='),
111 | key = decodeURIComponent(pair[0]);
112 | if (key) { data[key] = decodeURIComponent(pair[1]); }
113 | }
114 | return data;
115 | }
116 |
117 | // Regexs are based on parseUri 1.2.2
118 | // Original: (c) Steven Levithan
119 | // Original: MIT License
120 |
121 | var strictRegex = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/;
122 | var looseRegex = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
123 | var queryStringRegex = /(?:^|&)([^&=]*)=?([^&]*)/g;
124 |
125 | exports.parse = function(str, isStrict) {
126 | var regex = isStrict ? strictRegex : looseRegex;
127 | var result = {};
128 | var match = regex.exec(str);
129 | for (var i = 0, attr; attr = attrs[i]; ++i) {
130 | result[attr] = match[i] || "";
131 | }
132 |
133 | var qs = result['queryKey'] = {};
134 | result['query'].replace(queryStringRegex, function(check, key, val) {
135 | if (check) {
136 | qs[key] = val;
137 | }
138 | });
139 |
140 | return result;
141 | }
142 |
143 | exports.isSameDomain = function(urlA, urlB) {
144 | var a = exports.parse(urlA);
145 | var b = exports.parse(urlB);
146 | return ((a.port == b.port ) && (a.host == b.host) && (a.protocol == b.protocol));
147 | };
148 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/std/utf8.js:
--------------------------------------------------------------------------------
1 | /*
2 | Fast incremental JavaScript UTF-8 encoder/decoder, by Jacob Rus.
3 |
4 | API for decode from Orbited: as far as I know, the first incremental
5 | JavaScript UTF-8 decoder.
6 |
7 | Inspired by the observation by Johan Sundström published at:
8 | http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html
9 |
10 | Note that this code throws an error for invalid UTF-8. Because it is so much
11 | faster than previous implementations, the recommended way to do lenient
12 | parsing is to first try this decoder, and then fall back on a slower lenient
13 | decoder if necessary for the particular use case.
14 |
15 | --------------------
16 |
17 | Copyright (c) 2009 Jacob Rus
18 |
19 | Permission is hereby granted, free of charge, to any person
20 | obtaining a copy of this software and associated documentation
21 | files (the "Software"), to deal in the Software without
22 | restriction, including without limitation the rights to use,
23 | copy, modify, merge, publish, distribute, sublicense, and/or sell
24 | copies of the Software, and to permit persons to whom the
25 | Software is furnished to do so, subject to the following
26 | conditions:
27 |
28 | The above copyright notice and this permission notice shall be
29 | included in all copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
33 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
35 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
36 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
37 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
38 | OTHER DEALINGS IN THE SOFTWARE.
39 | */
40 | //var utf8 = this.utf8 = exports;
41 |
42 | exports.UnicodeCodecError = function (message) {
43 | this.message = message;
44 | };
45 |
46 | var UnicodeCodecError = exports.UnicodeCodecError;
47 |
48 | UnicodeCodecError.prototype.toString = function () {
49 | return 'UnicodeCodecError' + (this.message ? ': ' + this.message : '');
50 | };
51 |
52 | exports.encode = function (unicode_string) {
53 | // Unicode encoder: Given an arbitrary unicode string, returns a string
54 | // of characters with code points in range 0x00 - 0xFF corresponding to
55 | // the bytes of the utf-8 representation of those characters.
56 | try {
57 | return unescape(encodeURIComponent(unicode_string));
58 | }
59 | catch (err) {
60 | throw new UnicodeCodecError('invalid input string');
61 | };
62 | };
63 | exports.decode = function (bytes) {
64 | // Unicode decoder: Given a string of characters with code points in
65 | // range 0x00 - 0xFF, which, when interpreted as bytes, are valid UTF-8,
66 | // returns the corresponding Unicode string, along with the number of
67 | // bytes in the input string which were successfully parsed.
68 | //
69 | // Unlike most JavaScript utf-8 encode/decode implementations, properly
70 | // deals with partial multi-byte characters at the end of the byte string.
71 | if (/[^\x00-\xFF]/.test(bytes)) {
72 | throw new UnicodeCodecError('invalid utf-8 bytes');
73 | };
74 | var len, len_parsed;
75 | len = len_parsed = bytes.length;
76 | var last = len - 1;
77 | // test for non-ascii final byte. if last byte is ascii (00-7F) we're done.
78 | if (bytes.charCodeAt(last) >= 0x80) {
79 | // loop through last 3 bytes looking for first initial byte of unicode
80 | // multi-byte character. If the initial byte is 4th from the end, we'll
81 | // parse the whole string.
82 | for (var i = 1; i <= 3; i++) {
83 | // initial bytes are in range C0-FF
84 | if (bytes.charCodeAt(len - i) >= 0xC0) {
85 | len_parsed = len - i;
86 | break;
87 | };
88 | };
89 | try {
90 | // if the last few bytes are a complete multi-byte character, parse
91 | // everything (by setting len_parsed)
92 | decodeURIComponent(escape(bytes.slice(len_parsed)));
93 | len_parsed = len;
94 | }
95 | catch (err) { /* pass */ };
96 | };
97 | try {
98 | return [
99 | decodeURIComponent(escape(bytes.slice(0, len_parsed))),
100 | len_parsed
101 | ];
102 | }
103 | catch (err) {
104 | throw new UnicodeCodecError('invalid utf-8 bytes');
105 | };
106 | };
107 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/std/uuid.js:
--------------------------------------------------------------------------------
1 | /*
2 | Based on Math.uuid.js 1.4 by Robert Kieffer
3 |
4 | ----
5 | Copyright (c) 2008, Robert Kieffer
6 | All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 |
11 | * Redistributions of source code must retain the above copyright notice,
12 | this list of conditions and the following disclaimer.
13 | * Redistributions in binary form must reproduce the above copyright
14 | notice, this list of conditions and the following disclaimer in the
15 | documentation and/or other materials provided with the distribution.
16 | * Neither the name of Robert Kieffer nor the names of its contributors
17 | may be used to endorse or promote products derived from this software
18 | without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 | POSSIBILITY OF SUCH DAMAGE.
31 |
32 | */
33 |
34 |
35 |
36 | /*
37 | * Generate a random uuid.
38 | *
39 | * USAGE: uuid.uuid(length, radix)
40 | * length - the desired number of characters
41 | * radix - the number of allowable values for each character.
42 | *
43 | * EXAMPLES:
44 | * // No arguments - returns RFC4122, version 4 ID
45 | * >>> std.uuid()
46 | * "92329D39-6F5C-4520-ABFC-AAB64544E172"
47 | *
48 | * // One argument - returns ID of the specified length
49 | * >>> std.uuid(15) // 15 character ID (default base=62)
50 | * "VcydxgltxrVZSTV"
51 | *
52 | * // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
53 | * >>> std.uuid(8, 2) // 8 character ID (base=2)
54 | * "01001010"
55 | * >>> std.uuid(8, 10) // 8 character ID (base=10)
56 | * "47473046"
57 | * >>> std.uuid(8, 16) // 8 character ID (base=16)
58 | * "098F4D35"
59 | */
60 |
61 |
62 | var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
63 | exports.uuid = function (len, radix) {
64 | var chars = CHARS, uuid = [], rnd = Math.random;
65 | radix = radix || chars.length;
66 |
67 | if (len) {
68 | // Compact form
69 | for (var i = 0; i < len; i++) uuid[i] = chars[0 | rnd()*radix];
70 | } else {
71 | // rfc4122, version 4 form
72 | var r;
73 |
74 | // rfc4122 requires these characters
75 | uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
76 | uuid[14] = '4';
77 |
78 | // Fill in random data. At i==19 set the high bits of clock sequence as
79 | // per rfc4122, sec. 4.1.5
80 | for (var i = 0; i < 36; i++) {
81 | if (!uuid[i]) {
82 | r = 0 | rnd()*16;
83 | uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
84 | }
85 | }
86 | }
87 | return uuid.join('');
88 | };
89 |
90 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/util/Animation.js:
--------------------------------------------------------------------------------
1 | exports = Class(function() {
2 | this.init = function(params) {
3 | this._start = 'start' in params ? params.start : 0;
4 | this._end = 'end' in params ? params.end : 1;
5 | this._transition = params.transition || null;
6 | this._easing = params.easing || false;
7 | this._subject = params.subject;
8 | this._duration = params.duration || 1000;
9 | this._s = params.current || this._start;
10 | this._onFinish = params.onFinish || null;
11 |
12 | this._range = this._end - this._start;
13 | this._isAnimating = false;
14 | this._animate = bind(this, 'animate');
15 | this._timer = null;
16 | }
17 |
18 | this.seekTo = function(s, dur) {
19 | this._t0 = +new Date();
20 | this._s0 = this._s;
21 | this._s1 = s;
22 | if(dur) this._duration = dur;
23 |
24 | this._ds = s - this._s;
25 | var dt = this._ds / this._range * this._duration;
26 | this._dt = dt < 0 ? -dt : dt;
27 |
28 | if(!this._isAnimating) {
29 | this._isAnimating = true;
30 | this._timer = setInterval(this._animate, 15);
31 | }
32 |
33 | return this;
34 | }
35 |
36 | this.onFinish = function(onFinish) { this._onFinish = onFinish; return this; }
37 |
38 | this.jumpTo = function(s) {
39 | this._s1 = this._s0 = s;
40 | this._t0 = 0;
41 | this._dt = 1;
42 | this._ds = 0;
43 | this.animate();
44 | return this;
45 | }
46 |
47 | this.animate = function() {
48 | var dt = (new Date() - this._t0) / this._dt;
49 | if(dt > 1) { dt = 1; }
50 | this._s = this._s0 + dt * this._ds;
51 |
52 | var x = this._transition ? this._transition(this._s) : this._s;
53 | this._subject(this._start + this._range * x, this._s);
54 |
55 | if(dt == 1) {
56 | clearInterval(this._timer);
57 | this._isAnimating = false;
58 | if(this._onFinish) {
59 | this._onFinish();
60 | }
61 | }
62 | }
63 | });
64 |
65 | exports.linear = function (n) { return n; }
66 | exports.easeIn = function (n) { return n * n; }
67 | exports.easeInOut = function (n) { return (n *= 2) < 1 ? 0.5 * n * n * n : 0.5 * ((n -= 2) * n * n + 2); }
68 | exports.easeOut = function(n) { return n * (2 - n); }
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/util/browserdetect.js:
--------------------------------------------------------------------------------
1 | exports.BrowserDetect = new function() {
2 | var versionSearchString;
3 | var dataBrowser = [
4 | {
5 | string: navigator.userAgent,
6 | subString: "Chrome"
7 | },
8 | {
9 | string: navigator.userAgent,
10 | subString: "OmniWeb",
11 | versionSearch: "OmniWeb/"
12 | },
13 | {
14 | string: navigator.vendor,
15 | subString: "Apple",
16 | identity: "Safari",
17 | versionSearch: "Version"
18 | },
19 | {
20 | prop: window.opera,
21 | identity: "Opera"
22 | },
23 | {
24 | string: navigator.vendor,
25 | subString: "iCab"
26 | },
27 | {
28 | string: navigator.vendor,
29 | subString: "KDE",
30 | identity: "Konqueror"
31 | },
32 | {
33 | string: navigator.userAgent,
34 | subString: "Firefox"
35 | },
36 | {
37 | string: navigator.vendor,
38 | subString: "Camino"
39 | },
40 | { // for newer Netscapes (6+)
41 | string: navigator.userAgent,
42 | subString: "Netscape"
43 | },
44 | {
45 | string: navigator.userAgent,
46 | subString: "MSIE",
47 | identity: "IE",
48 | versionSearch: "MSIE"
49 | },
50 | {
51 | string: navigator.userAgent,
52 | subString: "Gecko",
53 | identity: "Mozilla",
54 | versionSearch: "rv"
55 | },
56 | { // for older Netscapes (4-)
57 | string: navigator.userAgent,
58 | subString: "Mozilla",
59 | identity: "Netscape",
60 | versionSearch: "Mozilla"
61 | }
62 | ];
63 |
64 | var dataOS = [
65 | {
66 | string: navigator.platform,
67 | subString: "Win",
68 | identity: "Windows"
69 | },
70 | {
71 | string: navigator.platform,
72 | subString: "Mac"
73 | },
74 | {
75 | string: navigator.userAgent,
76 | subString: "iPhone",
77 | identity: "iPhone/iPod"
78 | },
79 | {
80 | string: navigator.platform,
81 | subString: "Linux"
82 | }
83 | ];
84 |
85 | function searchString(data) {
86 | for (var i=0,item;item=data[i];i++) {
87 | var dataString = item.string;
88 | var dataProp = item.prop;
89 | item.identity = item.identity || item.subString;
90 | versionSearchString = item.versionSearch || item.identity;
91 | if (dataString) {
92 | if (dataString.indexOf(item.subString) != -1)
93 | return item.identity;
94 | } else if (dataProp)
95 | return item.identity;
96 | }
97 | }
98 |
99 | function searchVersion(dataString) {
100 | var index = dataString.indexOf(versionSearchString);
101 | if (index == -1) return;
102 | return parseFloat(dataString.substring(index+versionSearchString.length+1));
103 | }
104 |
105 | this.browser = searchString(dataBrowser) || "unknown";
106 | this.version = searchVersion(navigator.userAgent)
107 | || searchVersion(navigator.appVersion)
108 | || "unknown";
109 | this.OS = searchString(dataOS) || "unknown";
110 | this.isWebKit = RegExp(" AppleWebKit/").test(navigator.userAgent);
111 | this['is'+this.browser] = this.version;
112 | };
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/util/optparse.js:
--------------------------------------------------------------------------------
1 | "use import";
2 |
3 | import util.jsonSchema
4 | import lib.Enum;
5 |
6 | /* optparser */
7 |
8 | /*
9 |
10 | optsDef = {
11 | '-v': {
12 | name: 'version',
13 | description: 'prints the version information',
14 | args: {
15 | 0: '
16 | }
17 | }
18 | }
19 |
20 | */
21 |
22 | import std.js as JS;
23 |
24 | function ERROR(msg) {
25 | logger.error(msg);
26 | process.exit(1);
27 | }
28 |
29 | function addAlso(optsDef, also, value) {
30 | if (typeof also == 'string') {
31 | optsDef[also] = value;
32 | } else {
33 | logger.warn('Key specified in option', optsDef.name, 'is invalid. Ignoring:', also);
34 | }
35 | }
36 |
37 | var truthyValues = lib.Enum('true', '1', 'yes'),
38 | falsyValues = lib.Enum('false', '0', 'no');
39 |
40 | function addArg(result, optsDef, argv, i) {
41 | var val,
42 | srcName = argv[i],
43 | itemSchema = optsDef[argv[i]],
44 | len = argv.length,
45 | itemType = itemSchema.type.toLowerCase();
46 |
47 | ++i;
48 | switch(itemType) {
49 | case 'boolean':
50 | if (argv[i].toLowerCase() in truthyValues) {
51 | val = true;
52 | } else if (argv[i].toLowerCase() in falsyValues) {
53 | val = false;
54 | } else {
55 | val = true;
56 | --i;
57 | }
58 | break;
59 | case 'int':
60 | case 'integer':
61 | val = parseInt(argv[i]);
62 | break;
63 | case 'float':
64 | case 'double':
65 | case 'number':
66 | val = parseFloat(argv[i]);
67 | break;
68 | case 'array':
69 | case 'object':
70 | var buf = argv[i];
71 | while(true) {
72 | try {
73 | var val = eval('(' + buf + ')');
74 | break;
75 | } catch(e) {}
76 | ++i;
77 | if (i >= len) { ERROR('Could not parse "' + srcName + '": ' + itemSchema.type + '\n' + buf + '\n' + JSON.stringify(argv)); }
78 | buf += argv[i];
79 | }
80 | break;
81 | case 'any':
82 | case 'string':
83 | default:
84 | val = argv[i];
85 | break;
86 | }
87 |
88 | var status = util.jsonSchema.validate(val, itemSchema);
89 | if (status.valid) {
90 | result[itemSchema.name] = val;
91 | return i + 1;
92 | } else {
93 | var log = [];
94 | for(var k = 0, e; e = status.errors[k]; ++k) {
95 | log.push('\n\t\t' + (e.property ? e.property + ': ' : '') + e.message)
96 | }
97 |
98 | ERROR('\n' + srcName + ': provided value ' + argv[i] + '\n\t' + itemSchema.name + ' option:' + log.join(''));
99 | }
100 | }
101 |
102 | exports = function(argv, origDef) {
103 | var optsDef = JS.shallowCopy(origDef),
104 | result = {};
105 | for (var i in optsDef) {
106 | var opt = optsDef[i];
107 | if ('default' in opt) { result[opt.name] = opt.default; }
108 |
109 | var also = opt.also;
110 | if (also) {
111 | if (JS.isArray(also)) {
112 | for (var j = 0, len = also.length; j < len; ++j) {
113 | addAlso(optsDef, also[j], opt);
114 | }
115 | } else {
116 | addAlso(optsDef, also, opt);
117 | }
118 | }
119 | }
120 |
121 | var unprocessed = [],
122 | i = 0,
123 | len = argv.length;
124 |
125 | while (i < len) {
126 | if (argv[i] in optsDef) {
127 | i = addArg(result, optsDef, argv, i);
128 | } else {
129 | unprocessed.push(argv[i]);
130 | i++;
131 | }
132 | }
133 |
134 | return {
135 | args: unprocessed,
136 | opts: result
137 | };
138 | }
139 |
140 | exports.printUsage = function(usage, optsDef) {
141 | import util.wordWrap;
142 |
143 | var print = jsio.__env.log;
144 | print('Usage:');
145 | print('\t' + usage);
146 | print('Options:');
147 | for (var i in optsDef) {
148 | var opt = [i];
149 | if (optsDef[i].also) {
150 | if (JS.isArray(optsDef[i].also)) {
151 | opt = opt.concat(optsDef[i].also);
152 | } else {
153 | opt.push(optsDef[i].also);
154 | }
155 | }
156 | print('\t'+opt.join(', '));
157 | if (optsDef[i].description) {
158 | print(util.wordWrap(optsDef[i].description, 80, '\t\t'));
159 | }
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/util/path.js:
--------------------------------------------------------------------------------
1 | var util = jsio.__jsio.__util;
2 |
3 | exports.buildPath = util.buildPath;
4 | exports.resolveRelativePath = util.resolveRelativePath;
5 | exports.splitPath = util.splitPath;
6 | exports.makeRelativePath = util.makeRelativePath;
--------------------------------------------------------------------------------
/daemon/orbited2/js_src/jsio-3.3alpha/util/wordWrap.js:
--------------------------------------------------------------------------------
1 | exports = function(str, maxWidth, prefix, tabWidth) {
2 | prefix = prefix || '';
3 | maxWidth -= exports.getLengthWithTabs(prefix, tabWidth);
4 |
5 | if (!maxWidth) { return prefix + str; }
6 |
7 | var words = str.split(' '),
8 | numWords = words.length,
9 | lines = [{
10 | str: [],
11 | len: 0
12 | }],
13 | i = 0;
14 |
15 | function finalize() {
16 | lines[i] = prefix + curLine.str.join(' ');
17 | ++i;
18 | }
19 |
20 | var curLine = lines[i];
21 | for (var j = 0; j < numWords; ++j) {
22 | var word = words[j],
23 | wordLen = word.length;
24 | if (curLine.len && curLine.len + wordLen + 1 > maxWidth) {
25 | finalize();
26 | curLine = lines[i] = {str: [word], len: wordLen};
27 | } else {
28 | curLine.str.push(word);
29 | if (curLine.len) { curLine.len++; }
30 | curLine.len += wordLen;
31 | }
32 | }
33 |
34 | if (curLine.len) {
35 | finalize();
36 | } else {
37 | lines.pop();
38 | }
39 |
40 | return lines.join('\n');
41 | }
42 |
43 | exports.getLengthWithTabs = function(str, tabWidth) {
44 | var tabs = 0;
45 | str = str.replace(/\t/g, function() { ++tabs; });
46 | return str.length + tabs * (tabWidth || 8);
47 | }
48 |
--------------------------------------------------------------------------------
/daemon/orbited2/server.py:
--------------------------------------------------------------------------------
1 | import os
2 | import eventlet
3 | import eventlet.websocket
4 | import csp_eventlet
5 | import protocol
6 | import static
7 | from paste.urlmap import URLMap
8 |
9 | class OrbitedServer(object):
10 |
11 | def __init__(self, config):
12 | self._config = config
13 | self._csp_sock = csp_eventlet.Listener()
14 | self._init_listen_rules()
15 |
16 | def _init_listen_rules(self):
17 | self._wsgi_apps = {}
18 | static_path = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'static')
19 | for rule in self._config.rules['Listen']:
20 | wsgi_app = URLMap()
21 | wsgi_app['/static'] = static.Cling(static_path)
22 | if 'ws' in rule.protocols:
23 | wsgi_app['/ws'] = eventlet.websocket.WebSocketWSGI(self._wsgi_websocket)
24 | if 'csp' in rule.protocols:
25 | wsgi_app['/csp'] = self._csp_sock
26 | self._wsgi_apps[(rule.interface, rule.port)] = wsgi_app
27 |
28 |
29 | def run(self):
30 | for (iface, port), app in self._wsgi_apps.items():
31 | print "Orbited listening on http://%s:%s" % (iface or "0.0.0.0", port)
32 | eventlet.spawn(eventlet.wsgi.server, eventlet.listen((iface,port)), app, log=EmptyLogShim())
33 | ev = eventlet.event.Event()
34 | eventlet.spawn(self._run, ev)
35 | return ev
36 |
37 | def _run(self, ev):
38 | while True:
39 | try:
40 | csp_sock, addr = self._csp_sock.accept()
41 | eventlet.spawn(self._accepted, csp_sock, addr)
42 | except:
43 | ev.send_exception(*sys.exc_info())
44 | break
45 |
46 | def _accepted(self, sock, addr=None):
47 | p = protocol.OrbitedProtocol(self, self._config.rules['RemoteDestination'], sock, addr)
48 | p.run()
49 |
50 | def _wsgi_websocket(self, ws):
51 | self._accepted(SockWebSocketWrapper(ws))
52 |
53 |
54 | class SockWebSocketWrapper(object):
55 | def __init__(self, ws):
56 | self._ws = ws
57 |
58 | def recv(self, num):
59 | # not quite right (ignore num)... but close enough for our use.
60 | data = self._ws.wait()
61 | if data:
62 | data = data.encode('utf-8')
63 | return data
64 |
65 | def send(self, data):
66 | self._ws.send(data)
67 | return len(data)
68 |
69 | def sendall(self, data):
70 | self.send(data)
71 |
72 | def __getattr__(self, key):
73 | return getattr(self._ws, key)
74 |
75 | class EmptyLogShim(object):
76 | def write(self, *args, **kwargs):
77 | return
--------------------------------------------------------------------------------
/daemon/orbited2/start.py:
--------------------------------------------------------------------------------
1 | import server
2 | import config
3 | import sys
4 | import logging
5 |
6 |
7 | def main():
8 | logging.basicConfig()
9 | c = config.OrbitedConfig(sys.argv)
10 | s = server.OrbitedServer(c)
11 | ev = s.run()
12 | try:
13 | ev.wait()
14 | except KeyboardInterrupt:
15 | print "Caught Ctr-C; Closing."
16 | if __name__ == "__main__":
17 | main()
18 |
--------------------------------------------------------------------------------
/daemon/orbited2/static/Orbited2.min.js.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/daemon/orbited2/static/Orbited2.min.js.gz
--------------------------------------------------------------------------------
/daemon/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 | import os, sys
3 | import orbited2
4 |
5 | static_types = [
6 | '*.js',
7 | '*.gz',
8 | '*.html',
9 | '*.css',
10 | '*.ico',
11 | '*.gif',
12 | '*.jpg',
13 | '*.png',
14 | '*.txt*',
15 | '*.py',
16 | '*.template'
17 | ]
18 |
19 | #if sys.platform != "win32":
20 | # _install_requires.append("Twisted")
21 |
22 | def find_package_data():
23 | targets = [
24 | os.path.join('orbited2', 'static'),
25 | os.path.join('orbited2', 'admin', 'static')
26 | ]
27 | package_data = {'': reduce(list.__add__, [ '.git' not in d and [ os.path.join(d[len('orbited2/'):], e) for e in
28 | static_types ] or [] for (d, s, f) in reduce(list.__add__, [ [ i for i in os.walk(target) ] for target in targets ])
29 | ]) }
30 | return package_data
31 |
32 | def main():
33 | setup(
34 | name='orbited2',
35 | version=orbited2.__version__,
36 | author='Michael Carter',
37 | author_email='CarterMichael@gmail.com',
38 | url='http://www.github.com/mcarter/orbited2',
39 | license='MIT License',
40 | description='A WebSocket-enabling proxy, so you can code against Websocket in any browser.',
41 | long_description='',
42 | packages= find_packages(),
43 | package_data = find_package_data(),
44 | zip_safe = False,
45 | install_requires = ['csp_eventlet>=0.4.1', 'static', 'paste'],
46 | entry_points = '''
47 | [console_scripts]
48 | orbited2 = orbited2.start:main
49 | ''',
50 |
51 | classifiers = [
52 | 'Development Status :: 4 - Beta',
53 | 'Environment :: Console',
54 | 'Intended Audience :: Developers',
55 | 'License :: OSI Approved :: MIT License',
56 | 'Operating System :: OS Independent',
57 | 'Programming Language :: Python',
58 | 'Topic :: Software Development :: Libraries :: Python Modules'
59 | ],
60 | )
61 |
62 | if __name__ == '__main__':
63 | main()
64 |
--------------------------------------------------------------------------------
/docs/CREDITS:
--------------------------------------------------------------------------------
1 | This documentation was adapted from the SQLALchemy documentation sources.
2 |
3 | Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Michael Bayer and contributors.
4 | SQLAlchemy is a trademark of Michael Bayer.
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | PAPER =
8 | BUILDDIR = build
9 |
10 | # Internal variables.
11 | PAPEROPT_a4 = -D latex_paper_size=a4
12 | PAPEROPT_letter = -D latex_paper_size=letter
13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
14 |
15 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
16 |
17 | help:
18 | @echo "Please use \`make ' where is one of"
19 | @echo " html to make standalone HTML files"
20 | @echo " dirhtml to make HTML files named index.html in directories"
21 | @echo " pickle to make pickle files"
22 | @echo " json to make JSON files"
23 | @echo " htmlhelp to make HTML files and a HTML help project"
24 | @echo " qthelp to make HTML files and a qthelp project"
25 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
26 | @echo " changes to make an overview of all changed/added/deprecated items"
27 | @echo " linkcheck to check all external links for integrity"
28 | @echo " doctest to run all doctests embedded in the documentation (if enabled)"
29 |
30 | clean:
31 | -rm -rf $(BUILDDIR)/*
32 |
33 | html:
34 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
35 | @echo
36 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
37 |
38 | dirhtml:
39 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
40 | @echo
41 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
42 |
43 | pickle:
44 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
45 | @echo
46 | @echo "Build finished; now you can process the pickle files."
47 |
48 | json:
49 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
50 | @echo
51 | @echo "Build finished; now you can process the JSON files."
52 |
53 | htmlhelp:
54 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
55 | @echo
56 | @echo "Build finished; now you can run HTML Help Workshop with the" \
57 | ".hhp project file in $(BUILDDIR)/htmlhelp."
58 |
59 | qthelp:
60 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
61 | @echo
62 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \
63 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
64 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/hookbox.qhcp"
65 | @echo "To view the help file:"
66 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/hookbox.qhc"
67 |
68 | latex:
69 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
70 | @echo
71 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
72 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
73 | "run these through (pdf)latex."
74 |
75 | changes:
76 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
77 | @echo
78 | @echo "The overview file is in $(BUILDDIR)/changes."
79 |
80 | linkcheck:
81 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
82 | @echo
83 | @echo "Link check complete; look for any errors in the above output " \
84 | "or in $(BUILDDIR)/linkcheck/output.txt."
85 |
86 | doctest:
87 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
88 | @echo "Testing of doctests in the sources finished, look at the " \
89 | "results in $(BUILDDIR)/doctest/output.txt."
90 |
--------------------------------------------------------------------------------
/docs/build/doctrees/compilation.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/compilation.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/configuration.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/configuration.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/deployment.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/deployment.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/environment.pickle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/environment.pickle
--------------------------------------------------------------------------------
/docs/build/doctrees/index.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/index.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/intro.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/intro.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/tcpsocket.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/tcpsocket.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/under_the_hood.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/under_the_hood.doctree
--------------------------------------------------------------------------------
/docs/build/doctrees/websocket.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/doctrees/websocket.doctree
--------------------------------------------------------------------------------
/docs/build/html/.buildinfo:
--------------------------------------------------------------------------------
1 | # Sphinx build info version 1
2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3 | config: d14059706370c86b2bd2ca452d8be6b9
4 | tags: fbb0d17656682115ca4d033fb2f83ba1
5 |
--------------------------------------------------------------------------------
/docs/build/html/_sources/compilation.txt:
--------------------------------------------------------------------------------
1 | ===========
2 | Compilation
3 | ===========
4 |
5 | Curious users may wish to modify the source code and recompile Orbited2. Here's how, courtesy of Niklas.
6 |
7 | 1. Check-out js.io from github (https://github.com/gameclosure/js.io)
8 | 2. Make a symlink from js.io/jsio to /usr/bin/jsio (for easier use)
9 | 3. Enter daemon/orbited/js_src and make sure your orbited.pkg looks something like this:
10 |
11 | .. code-block:: none
12 |
13 | {
14 | "root": "./Orbited2",
15 | "externalName": "Orbited2",
16 | "transports": ["csp", "websocket"],
17 | "environments": ["browser"],
18 | "additional_dependancies": [ ]
19 | }
20 |
21 | 4. Compile the source (while in js_src) with:
22 |
23 | .. code-block:: none
24 |
25 | jsio compile Orbited2.pkg -o Orbited2-new.js
26 |
27 | 5. You're done. Celebrate!
--------------------------------------------------------------------------------
/docs/build/html/_sources/configuration.txt:
--------------------------------------------------------------------------------
1 | =============
2 | Configuration
3 | =============
4 |
5 | Orbited2 takes a single command line argument, -c (or --config) and the file location of your config file. The default is orbited2.cfg. This config file has two directives.
6 |
7 | Overview
8 | ========
9 |
10 | A user would run:
11 |
12 | .. code-block:: none
13 |
14 | user@host:~# orbited2 --config /etc/orbited2.cfg
15 |
16 | A configuration example:
17 |
18 | .. code-block:: python
19 |
20 | # Contents of /etc/orbited2.cfg
21 |
22 | # Access Control
23 |
24 | RemoteDestination(
25 | name="ws_echo", # for logging purposes
26 | hostname="127.0.0.1",
27 | port=8083,
28 | host_header = '*', # let any scripts from anywhere access this remote destination
29 | protocol="ws/hixie76" # normalize outgoing connections to WebSocket draft 76
30 | )
31 |
32 | # Listen
33 |
34 | Listen (
35 | port=8000,
36 | interface="0.0.0.0" # bind to all ports
37 | )
38 |
39 |
40 |
41 | RemoteDestination
42 | =================
43 |
44 | The RemoteDestination directive specifies a remote server that Orbited2 will proxy to. If a webpage tries to use Orbited2 to open a connection to a remote destination that has no corresponding RemoteDestination directive, the connection will be denied. You may have as many remote destinations as you like, so long as they are each given a unique name.
45 |
46 | name (required)
47 | ---------------
48 |
49 | Unique name for logging purposes
50 |
51 | hostname (required)
52 | -------------------
53 |
54 | Destination hostname. This is a string that may represent either an ip address or a hostname.
55 |
56 | port (required)
57 | ---------------
58 |
59 | Destination port; an integer.
60 |
61 | host_header (required)
62 | ----------------------
63 |
64 | All connections to this remote destination via orbited will only be authorized if the "Host" header in the initial HTTP request matches the value of this rule. This value should just be the domain name of your website, in most cases. For testing purposes you may put a '*' here.
65 |
66 | protocol
67 | --------
68 |
69 | The outgoing protocol. The default is "ws/hixie76". Valid options are: "tcp", "ws/hixie75", and "ws/hixie76". We will support new versions of the WebSocket protocol as they are released.
70 |
71 | If you are using the Orbited.TCPSocket javascript api, then the value of protocol must be 'tcp'.
72 |
73 | If you are using the Orbited.WebSocket.install javascript api, the `protocolVersion` value given there should match the revision number given here.
74 |
75 |
76 | Listen
77 | ======
78 |
79 | The Listen directive specifies an interface and port where Orbited2 should listen, as well as a set of protocols it should listen for. You may have as many Listen directives as you like. An example
80 |
81 | .. sourcecode:: python
82 |
83 | Listen (
84 | port=8000,
85 | interface="0.0.0.0"
86 | )
87 |
88 |
89 | interface (required)
90 | --------------------
91 |
92 | A string representing the interface that hookbox should bind to.
93 |
94 |
95 | port (required)
96 | ---------------
97 |
98 | An integer specifying the port that hookbox should bind to.
99 |
100 |
--------------------------------------------------------------------------------
/docs/build/html/_sources/deployment.txt:
--------------------------------------------------------------------------------
1 | ==========
2 | Deployment
3 | ==========
4 |
5 | Orbited2 takes a single command line argument, -c (or --config) and the file location of your config file. The default is orbited2.cfg. Thus, deployment consists of creating a suitable orbited2.cfg and typing:
6 |
7 | .. sourcecode:: none
8 |
9 | # orbited2
10 |
11 |
--------------------------------------------------------------------------------
/docs/build/html/_sources/index.txt:
--------------------------------------------------------------------------------
1 | .. orbited2 documentation master file, created by
2 | sphinx-quickstart on Tue Apr 27 06:40:43 2010.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Orbited2 Documentation
7 | ======================
8 |
9 | Contents:
10 |
11 | .. toctree::
12 | :maxdepth: 2
13 |
14 | intro
15 | configuration
16 | deployment
17 | compilation
--------------------------------------------------------------------------------
/docs/build/html/_sources/intro.txt:
--------------------------------------------------------------------------------
1 | ============
2 | Introduction
3 | ============
4 |
5 | Overview
6 | ========
7 |
8 | Orbited2's purpose is to ease the development of Websocket-based applications by normalizing the protocol and api across varying browser and server implementations.
9 |
10 |
11 | #. Choose a WebSocket server framework/library (like node.js, or eventlet.)
12 | #. Write a WebSocket application.
13 | #. Deploy Orbited2. It will put a normalized Websocket API in *all* browsers.
14 |
15 |
16 |
17 | The Problem
18 | -----------
19 |
20 | WebSocket is a far better real-time web protocol than anything we've seen so far, but it only works in a couple of the latest browsers. Additionally, the protocol is so new that it changes very quickly; a WebSocket application you write today might well stop working tomorrow. Further compounding the problem are the multitude of entrenched intermediaries, namely forward proxies, reverse proxies, firewalls, virus scanners, and more -- these obstacles will intercept and deny WebSocket connections.
21 |
22 | The Solution
23 | ------------
24 |
25 | This code works in *all* browsers, and it will always use the best communication mechanism possible.
26 |
27 | .. sourcecode:: html
28 |
29 |
30 |
31 |
32 | .. sourcecode:: javascript
33 |
34 | Orbited2.WebSocket.install({
35 | protocolVersion: "hixie76",
36 | })
37 |
38 | var ws = new WebSocket('ws://example.com/app')
39 |
40 |
41 | Orbited Veterans
42 | ----------------
43 |
44 | For all of you Orbited veterans who aren't so sure about writing WebSocket servers, and you just want to keep using trusty old Orbited.TCPSocket (but with performance and usability improvments) -- don't worry!
45 |
46 | .. sourcecode:: html
47 |
48 |
49 |
50 |
51 | .. sourcecode:: javascript
52 |
53 | var sock = new Orbited2.TCPSocket({ orbitedUri: "http://127.0.0.1:8000" })
54 | sock.open("irc.freenode.org", 6667);
55 | sock.onopen = function() {
56 | sock.send('NICK mcarter\r\n');
57 | }
58 | //etc
59 |
60 |
61 | Installation
62 | ============
63 |
64 | Orbited2 is written in python and depends on setuptools for installation. The easiest way to install Orbited2 is to type:
65 |
66 | .. sourcecode:: none
67 |
68 | # easy_install orbited2
69 |
70 |
71 | If you are missing python or setuptools, please refer to the following links:
72 |
73 | * `install python `_
74 | * `install setuptools `_
75 |
76 | To confirm your installation succeeded, type:
77 |
78 | .. sourcecode:: none
79 |
80 | # orbited2 --help
81 |
82 | Github
83 | ======
84 |
85 | The development version of Orbited2 is located on github:
86 |
87 | * http://github.com/mcarter/orbited2
88 |
89 | You can get a copy of the latest source by cloning the repository:
90 |
91 | .. sourcecode:: none
92 |
93 | # git clone git://github.com/mcarter/orbited2.git
94 |
95 |
96 | To install Orbited2 from source, ensure you have python and setuptools, then run:
97 |
98 |
99 | .. sourcecode:: none
100 |
101 | # cd orbited2/daemon
102 | # python setup.py install
103 |
--------------------------------------------------------------------------------
/docs/build/html/_static/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/html/_static/file.png
--------------------------------------------------------------------------------
/docs/build/html/_static/init.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 | $('div.popup_sql').hide();
3 | $('a.sql_link').click(function() {
4 | $(this).nextAll('div.popup_sql:first').toggle();
5 | return false;
6 | })
7 | });
8 |
--------------------------------------------------------------------------------
/docs/build/html/_static/minus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/html/_static/minus.png
--------------------------------------------------------------------------------
/docs/build/html/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/build/html/_static/plus.png
--------------------------------------------------------------------------------
/docs/build/html/_static/pygments.css:
--------------------------------------------------------------------------------
1 | .hll { background-color: #ffffcc }
2 | .c { color: #408090; font-style: italic } /* Comment */
3 | .err { border: 1px solid #FF0000 } /* Error */
4 | .k { color: #007020; font-weight: bold } /* Keyword */
5 | .o { color: #666666 } /* Operator */
6 | .cm { color: #408090; font-style: italic } /* Comment.Multiline */
7 | .cp { color: #007020 } /* Comment.Preproc */
8 | .c1 { color: #408090; font-style: italic } /* Comment.Single */
9 | .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
10 | .gd { color: #A00000 } /* Generic.Deleted */
11 | .ge { font-style: italic } /* Generic.Emph */
12 | .gr { color: #FF0000 } /* Generic.Error */
13 | .gh { color: #000080; font-weight: bold } /* Generic.Heading */
14 | .gi { color: #00A000 } /* Generic.Inserted */
15 | .go { color: #303030 } /* Generic.Output */
16 | .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
17 | .gs { font-weight: bold } /* Generic.Strong */
18 | .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
19 | .gt { color: #0040D0 } /* Generic.Traceback */
20 | .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
21 | .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
22 | .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
23 | .kp { color: #007020 } /* Keyword.Pseudo */
24 | .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
25 | .kt { color: #902000 } /* Keyword.Type */
26 | .m { color: #208050 } /* Literal.Number */
27 | .s { color: #4070a0 } /* Literal.String */
28 | .na { color: #4070a0 } /* Name.Attribute */
29 | .nb { color: #007020 } /* Name.Builtin */
30 | .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
31 | .no { color: #60add5 } /* Name.Constant */
32 | .nd { color: #555555; font-weight: bold } /* Name.Decorator */
33 | .ni { color: #d55537; font-weight: bold } /* Name.Entity */
34 | .ne { color: #007020 } /* Name.Exception */
35 | .nf { color: #06287e } /* Name.Function */
36 | .nl { color: #002070; font-weight: bold } /* Name.Label */
37 | .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
38 | .nt { color: #062873; font-weight: bold } /* Name.Tag */
39 | .nv { color: #bb60d5 } /* Name.Variable */
40 | .ow { color: #007020; font-weight: bold } /* Operator.Word */
41 | .w { color: #bbbbbb } /* Text.Whitespace */
42 | .mf { color: #208050 } /* Literal.Number.Float */
43 | .mh { color: #208050 } /* Literal.Number.Hex */
44 | .mi { color: #208050 } /* Literal.Number.Integer */
45 | .mo { color: #208050 } /* Literal.Number.Oct */
46 | .sb { color: #4070a0 } /* Literal.String.Backtick */
47 | .sc { color: #4070a0 } /* Literal.String.Char */
48 | .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
49 | .s2 { color: #4070a0 } /* Literal.String.Double */
50 | .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
51 | .sh { color: #4070a0 } /* Literal.String.Heredoc */
52 | .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
53 | .sx { color: #c65d09 } /* Literal.String.Other */
54 | .sr { color: #235388 } /* Literal.String.Regex */
55 | .s1 { color: #4070a0 } /* Literal.String.Single */
56 | .ss { color: #517918 } /* Literal.String.Symbol */
57 | .bp { color: #007020 } /* Name.Builtin.Pseudo */
58 | .vc { color: #bb60d5 } /* Name.Variable.Class */
59 | .vg { color: #bb60d5 } /* Name.Variable.Global */
60 | .vi { color: #bb60d5 } /* Name.Variable.Instance */
61 | .il { color: #208050 } /* Literal.Number.Integer.Long */
--------------------------------------------------------------------------------
/docs/build/html/deployment.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Deployment
10 | — orbited2 v0.2.0 documentation
11 |
12 |
13 |
14 |
15 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | orbited2 v0.2.0 documentation
41 |
42 |
43 | Search:
44 |
49 |
50 |
51 |
54 |
55 |
56 |
57 |
58 |
API Reference
59 | |
60 |
Index
61 |
62 |
63 |
64 |
65 |
66 |
Table of Contents
67 | »
68 | Deployment
69 |
70 |
71 |
72 |
78 |
79 |
80 |
81 | Deployment
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
Deployment
93 |
Orbited2 takes a single command line argument, -c (or –config) and the file location of your config file. The default is orbited2.cfg. Thus, deployment consists of creating a suitable orbited2.cfg and typing:
94 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
111 |
112 |
113 | © Copyright 2010, Michael Carter.
114 | Created using
Sphinx 0.6.4.
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/build/html/genindex.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | Index — orbited2 v0.2.0 documentation
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | orbited2 v0.2.0 documentation
37 |
38 |
39 | Search:
40 |
45 |
46 |
47 |
50 |
51 |
52 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
Index
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | © Copyright 2010, Michael Carter.
101 | Created using
Sphinx 0.6.4.
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/docs/build/html/objects.inv:
--------------------------------------------------------------------------------
1 | # Sphinx inventory version 1
2 | # Project: orbited2
3 | # Version: 0.2
4 |
--------------------------------------------------------------------------------
/docs/build/html/search.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 | Search — orbited2 v0.2.0 documentation
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | orbited2 v0.2.0 documentation
38 |
39 |
40 | Search:
41 |
46 |
47 |
48 |
51 |
52 |
53 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
Enter Search Terms:
85 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | © Copyright 2010, Michael Carter.
109 | Created using
Sphinx 0.6.4.
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/docs/build/html/searchindex.js:
--------------------------------------------------------------------------------
1 | Search.setIndex({desctypes:{},terms:{all:[2,3],code:[1,2],protocol:[2,3],help:2,just:[2,3],enter:1,multitud:2,celebr:1,js_src:1,tcp:3,pkg:1,file:[3,4],follow:2,vari:2,line:[3,4],protocolvers:[2,3],access:3,onli:[2,3],firewal:2,locat:[2,3,4],listen:[0,3],how:1,configur:[0,3],solut:2,send:2,should:3,better:2,outgo:3,creat:4,curiou:1,might:2,easier:1,match:3,suitabl:4,bin:1,applic:2,sourc:[1,2],string:3,thei:3,get:2,webpag:3,than:2,stop:2,initi:3,number:3,framework:2,mechan:2,compound:2,veri:2,requir:3,introduct:[0,2],tri:3,daemon:[1,2],document:0,name:[2,3],anyth:2,revers:2,integ:3,server:[2,3],hixie76:[2,3],hixie75:3,either:3,each:3,where:3,librari:2,compil:[0,1],jsio:1,domain:3,set:3,old:2,additional_depend:1,direct:3,sure:[1,2],"static":2,connect:[2,3],further:2,port:3,best:2,out:1,confirm:2,open:[2,3],someth:1,normal:[2,3],your:[1,2,3,4],content:[0,3],written:2,version:[2,3],trusti:2,"new":[1,2,3],irc:2,across:2,refer:2,run:[2,3],proxi:[2,3],gameclosur:1,web:2,javascript:3,symlink:1,like:[1,2,3],host:3,succeed:2,let:3,here:[1,3],host_head:3,address:3,releas:3,depend:2,modifi:1,valu:3,src:2,about:2,orbited2:[0,1,2,3,4],coupl:2,most:3,script:[2,3],keep:2,etc:[2,3],base:2,real:2,mani:3,implement:2,com:[1,2],pleas:2,via:3,repositori:2,overview:[0,2,3],app:2,deploi:2,easy_instal:2,two:3,put:[2,3],api:[2,3],done:1,"long":3,org:2,ensur:2,instal:[0,2,3],nikla:1,miss:2,tomorrow:2,take:[3,4],given:3,git:2,from:[1,2,3],log:3,wai:2,commun:2,aren:2,support:3,sock:2,obstacl:2,todai:2,websit:3,draft:3,usr:1,cfg:[3,4],forward:2,interfac:3,type:[2,4],quickli:2,"function":2,option:3,onopen:2,python:2,addition:2,setuptool:2,specifi:3,anywher:3,"var":2,tcpsocket:[2,3],link:2,mcarter:2,eas:2,destin:3,easiest:2,freenod:2,must:3,"case":3,look:1,consist:4,possibl:2,"default":[3,4],wish:1,setup:2,work:2,uniqu:3,"while":1,can:2,purpos:[2,3],externalnam:1,problem:2,more:2,root:1,browser:[1,2],control:3,orbiteduri:2,would:3,websocket:[1,2,3],scanner:2,intercept:2,viru:2,request:3,orbit:[1,2,3],argument:[3,4],worri:2,repres:3,have:[2,3],hookbox:3,seen:2,revis:3,check:1,alwai:2,develop:2,want:2,author:3,perform:2,make:1,header:3,intermediari:2,write:2,nick:2,valid:3,transport:1,remotedestin:[0,3],test:3,command:[3,4],you:[1,2,3],entrench:2,config:[3,4],csp:1,singl:[3,4],node:2,courtesi:1,copi:2,http:[1,2,3],hostnam:3,deploy:[0,4],clone:2,who:2,ws_echo:3,usabl:2,remot:3,user:[1,3],improv:2,mai:[1,3],chang:2,github:[0,1,2],don:2,choos:2,ani:3,bind:3,thu:4,eventlet:2,well:[2,3],correspond:3,rule:3,recompil:1,deni:[2,3],exampl:[2,3],environ:1,thi:[1,2,3],time:2,far:2,veteran:2,latest:2},titles:["Orbited2 Documentation","Compilation","Introduction","Configuration","Deployment"],modules:{},descrefs:{},filenames:["index","compilation","intro","configuration","deployment"]})
--------------------------------------------------------------------------------
/docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | REM Command file for Sphinx documentation
4 |
5 | set SPHINXBUILD=sphinx-build
6 | set BUILDDIR=build
7 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
8 | if NOT "%PAPER%" == "" (
9 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
10 | )
11 |
12 | if "%1" == "" goto help
13 |
14 | if "%1" == "help" (
15 | :help
16 | echo.Please use `make ^` where ^ is one of
17 | echo. html to make standalone HTML files
18 | echo. dirhtml to make HTML files named index.html in directories
19 | echo. pickle to make pickle files
20 | echo. json to make JSON files
21 | echo. htmlhelp to make HTML files and a HTML help project
22 | echo. qthelp to make HTML files and a qthelp project
23 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
24 | echo. changes to make an overview over all changed/added/deprecated items
25 | echo. linkcheck to check all external links for integrity
26 | echo. doctest to run all doctests embedded in the documentation if enabled
27 | goto end
28 | )
29 |
30 | if "%1" == "clean" (
31 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
32 | del /q /s %BUILDDIR%\*
33 | goto end
34 | )
35 |
36 | if "%1" == "html" (
37 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
38 | echo.
39 | echo.Build finished. The HTML pages are in %BUILDDIR%/html.
40 | goto end
41 | )
42 |
43 | if "%1" == "dirhtml" (
44 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
45 | echo.
46 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
47 | goto end
48 | )
49 |
50 | if "%1" == "pickle" (
51 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
52 | echo.
53 | echo.Build finished; now you can process the pickle files.
54 | goto end
55 | )
56 |
57 | if "%1" == "json" (
58 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
59 | echo.
60 | echo.Build finished; now you can process the JSON files.
61 | goto end
62 | )
63 |
64 | if "%1" == "htmlhelp" (
65 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
66 | echo.
67 | echo.Build finished; now you can run HTML Help Workshop with the ^
68 | .hhp project file in %BUILDDIR%/htmlhelp.
69 | goto end
70 | )
71 |
72 | if "%1" == "qthelp" (
73 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
74 | echo.
75 | echo.Build finished; now you can run "qcollectiongenerator" with the ^
76 | .qhcp project file in %BUILDDIR%/qthelp, like this:
77 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\hookbox.qhcp
78 | echo.To view the help file:
79 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\hookbox.ghc
80 | goto end
81 | )
82 |
83 | if "%1" == "latex" (
84 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
85 | echo.
86 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
87 | goto end
88 | )
89 |
90 | if "%1" == "changes" (
91 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
92 | echo.
93 | echo.The overview file is in %BUILDDIR%/changes.
94 | goto end
95 | )
96 |
97 | if "%1" == "linkcheck" (
98 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
99 | echo.
100 | echo.Link check complete; look for any errors in the above output ^
101 | or in %BUILDDIR%/linkcheck/output.txt.
102 | goto end
103 | )
104 |
105 | if "%1" == "doctest" (
106 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
107 | echo.
108 | echo.Testing of doctests in the sources finished, look at the ^
109 | results in %BUILDDIR%/doctest/output.txt.
110 | goto end
111 | )
112 |
113 | :end
114 |
--------------------------------------------------------------------------------
/docs/source/_static/init.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 | $('div.popup_sql').hide();
3 | $('a.sql_link').click(function() {
4 | $(this).nextAll('div.popup_sql:first').toggle();
5 | return false;
6 | })
7 | });
8 |
--------------------------------------------------------------------------------
/docs/source/_templates/genindex.mako:
--------------------------------------------------------------------------------
1 | <%inherit file="layout.mako"/>
2 |
3 | <%def name="show_title()">${_('Index')}%def>
4 |
5 | ${_('Index')}
6 |
7 | % for i, (key, dummy) in enumerate(genindexentries):
8 | ${i != 0 and '| ' or ''}${key}
9 | % endfor
10 |
11 |
12 |
13 | % for i, (key, entries) in enumerate(genindexentries):
14 | ${key}
15 |
16 |
17 | <%
18 | breakat = genindexcounts[i] // 2
19 | numcols = 1
20 | numitems = 0
21 | %>
22 | % for entryname, (links, subitems) in entries:
23 |
24 |
25 | % if links:
26 | ${entryname|h}
27 | % for link in links[1:]:
28 | , [${i}]
29 | % endfor
30 | % else:
31 | ${entryname|h}
32 | % endif
33 |
34 | % if subitems:
35 |
36 | % for subentryname, subentrylinks in subitems:
37 | ${subentryname|h}
38 | % for j, link in enumerate(subentrylinks[1:]):
39 | [${j}]
40 | % endfor
41 |
42 | % endfor
43 |
44 | % endif
45 | <%
46 | numitems = numitems + 1 + len(subitems)
47 | %>
48 | % if numcols <2 and numitems > breakat:
49 | <%
50 | numcols = numcols + 1
51 | %>
52 |
53 | % endif
54 |
55 | % endfor
56 |
57 | % endfor
58 |
59 | <%def name="sidebarrel()">
60 | % if split_index:
61 | ${_('Index')}
62 |
63 | % for i, (key, dummy) in enumerate(genindexentries):
64 | ${i > 0 and '| ' or ''}
65 | ${key}
66 | % endfor
67 |
68 |
69 | ${_('Full index on one page')}
70 | % endif
71 | ${parent.sidebarrel()}
72 | %def>
73 |
--------------------------------------------------------------------------------
/docs/source/_templates/page.mako:
--------------------------------------------------------------------------------
1 | <%inherit file="layout.mako"/>
2 | ${body| util.strip_toplevel_anchors}
--------------------------------------------------------------------------------
/docs/source/_templates/search.mako:
--------------------------------------------------------------------------------
1 | <%inherit file="layout.mako"/>
2 |
3 | <%!
4 | local_script_files = ['_static/searchtools.js']
5 | %>
6 | <%def name="show_title()">${_('Search')}%def>
7 |
8 |
9 |
Enter Search Terms:
10 |
15 |
16 |
17 |
18 |
19 | <%def name="footer()">
20 | ${parent.footer()}
21 |
22 | %def>
23 |
--------------------------------------------------------------------------------
/docs/source/_templates/site_base.mako:
--------------------------------------------------------------------------------
1 | <%text>#coding:utf-8
2 | <%inherit file="/base.html"/>
3 | <%page cache_type="file" cached="True"/>
4 | <%!
5 | in_docs=True
6 | %>
7 | %text>
8 |
9 |
13 |
14 | ${'<%text>'}
15 | ${next.body()}
16 | ${'%text>'}
17 |
18 | <%text><%def name="style()">%text>
19 | ${self.headers()}
20 | <%text>${parent.style()}%text>
21 |
22 | <%text>%def>%text>
23 |
24 | <%text><%def name="title()">%text>${capture(self.show_title)|util.striptags} — ${docstitle|h}<%text>%def>%text>
25 |
26 | <%!
27 | local_script_files = []
28 | %>
29 |
--------------------------------------------------------------------------------
/docs/source/_templates/static_base.mako:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | ${metatags and metatags or ''}
8 | ${capture(self.show_title)|util.striptags} — ${docstitle|h}
9 | ${self.headers()}
10 |
11 |
12 | ${next.body()}
13 |
14 |
15 |
16 |
17 | <%!
18 | local_script_files = []
19 | %>
20 |
--------------------------------------------------------------------------------
/docs/source/builder/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/source/builder/__init__.py
--------------------------------------------------------------------------------
/docs/source/builder/util.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 | def striptags(text):
4 | return re.compile(r'<[^>]*>').sub('', text)
5 |
6 | def strip_toplevel_anchors(text):
7 | return re.compile(r'\.html#\w+-toplevel').sub('.html', text)
8 |
9 |
--------------------------------------------------------------------------------
/docs/source/compilation.rst:
--------------------------------------------------------------------------------
1 | ===========
2 | Compilation
3 | ===========
4 |
5 | Curious users may wish to modify the source code and recompile Orbited2. Here's how, courtesy of Niklas.
6 |
7 | 1. Check-out js.io from github (https://github.com/gameclosure/js.io)
8 | 2. Make a symlink from js.io/jsio to /usr/bin/jsio (for easier use)
9 | 3. Enter daemon/orbited/js_src and make sure your orbited.pkg looks something like this:
10 |
11 | .. code-block:: none
12 |
13 | {
14 | "root": "./Orbited2",
15 | "externalName": "Orbited2",
16 | "transports": ["csp", "websocket"],
17 | "environments": ["browser"],
18 | "additional_dependancies": [ ]
19 | }
20 |
21 | 4. Compile the source (while in js_src) with:
22 |
23 | .. code-block:: none
24 |
25 | jsio compile Orbited2.pkg -o Orbited2-new.js
26 |
27 | 5. You're done. Celebrate!
--------------------------------------------------------------------------------
/docs/source/configuration.rst:
--------------------------------------------------------------------------------
1 | =============
2 | Configuration
3 | =============
4 |
5 | Orbited2 takes a single command line argument, -c (or --config) and the file location of your config file. The default is orbited2.cfg. This config file has two directives.
6 |
7 | Overview
8 | ========
9 |
10 | A user would run:
11 |
12 | .. code-block:: none
13 |
14 | user@host:~# orbited2 --config /etc/orbited2.cfg
15 |
16 | A configuration example:
17 |
18 | .. code-block:: python
19 |
20 | # Contents of /etc/orbited2.cfg
21 |
22 | # Access Control
23 |
24 | RemoteDestination(
25 | name="ws_echo", # for logging purposes
26 | hostname="127.0.0.1",
27 | port=8083,
28 | host_header = '*', # let any scripts from anywhere access this remote destination
29 | protocol="ws/hixie76" # normalize outgoing connections to WebSocket draft 76
30 | )
31 |
32 | # Listen
33 |
34 | Listen (
35 | port=8000,
36 | interface="0.0.0.0" # bind to all ports
37 | )
38 |
39 |
40 |
41 | RemoteDestination
42 | =================
43 |
44 | The RemoteDestination directive specifies a remote server that Orbited2 will proxy to. If a webpage tries to use Orbited2 to open a connection to a remote destination that has no corresponding RemoteDestination directive, the connection will be denied. You may have as many remote destinations as you like, so long as they are each given a unique name.
45 |
46 | name (required)
47 | ---------------
48 |
49 | Unique name for logging purposes
50 |
51 | hostname (required)
52 | -------------------
53 |
54 | Destination hostname. This is a string that may represent either an ip address or a hostname.
55 |
56 | port (required)
57 | ---------------
58 |
59 | Destination port; an integer.
60 |
61 | host_header (required)
62 | ----------------------
63 |
64 | All connections to this remote destination via orbited will only be authorized if the "Host" header in the initial HTTP request matches the value of this rule. This value should just be the domain name of your website, in most cases. For testing purposes you may put a '*' here.
65 |
66 | protocol
67 | --------
68 |
69 | The outgoing protocol. The default is "ws/hixie76". Valid options are: "tcp", "ws/hixie75", and "ws/hixie76". We will support new versions of the WebSocket protocol as they are released.
70 |
71 | If you are using the Orbited.TCPSocket javascript api, then the value of protocol must be 'tcp'.
72 |
73 | If you are using the Orbited.WebSocket.install javascript api, the `protocolVersion` value given there should match the revision number given here.
74 |
75 |
76 | Listen
77 | ======
78 |
79 | The Listen directive specifies an interface and port where Orbited2 should listen, as well as a set of protocols it should listen for. You may have as many Listen directives as you like. An example
80 |
81 | .. sourcecode:: python
82 |
83 | Listen (
84 | port=8000,
85 | interface="0.0.0.0"
86 | )
87 |
88 |
89 | interface (required)
90 | --------------------
91 |
92 | A string representing the interface that hookbox should bind to.
93 |
94 |
95 | port (required)
96 | ---------------
97 |
98 | An integer specifying the port that hookbox should bind to.
99 |
100 |
--------------------------------------------------------------------------------
/docs/source/deployment.rst:
--------------------------------------------------------------------------------
1 | ==========
2 | Deployment
3 | ==========
4 |
5 | Orbited2 takes a single command line argument, -c (or --config) and the file location of your config file. The default is orbited2.cfg. Thus, deployment consists of creating a suitable orbited2.cfg and typing:
6 |
7 | .. sourcecode:: none
8 |
9 | # orbited2
10 |
11 |
--------------------------------------------------------------------------------
/docs/source/diagrams/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/docs/source/diagrams/overview.png
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. orbited2 documentation master file, created by
2 | sphinx-quickstart on Tue Apr 27 06:40:43 2010.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Orbited2 Documentation
7 | ======================
8 |
9 | Contents:
10 |
11 | .. toctree::
12 | :maxdepth: 2
13 |
14 | intro
15 | configuration
16 | deployment
17 | compilation
--------------------------------------------------------------------------------
/docs/source/intro.rst:
--------------------------------------------------------------------------------
1 | ============
2 | Introduction
3 | ============
4 |
5 | Overview
6 | ========
7 |
8 | Orbited2's purpose is to ease the development of Websocket-based applications by normalizing the protocol and api across varying browser and server implementations.
9 |
10 |
11 | #. Choose a WebSocket server framework/library (like node.js, or eventlet.)
12 | #. Write a WebSocket application.
13 | #. Deploy Orbited2. It will put a normalized Websocket API in *all* browsers.
14 |
15 |
16 |
17 | The Problem
18 | -----------
19 |
20 | WebSocket is a far better real-time web protocol than anything we've seen so far, but it only works in a couple of the latest browsers. Additionally, the protocol is so new that it changes very quickly; a WebSocket application you write today might well stop working tomorrow. Further compounding the problem are the multitude of entrenched intermediaries, namely forward proxies, reverse proxies, firewalls, virus scanners, and more -- these obstacles will intercept and deny WebSocket connections.
21 |
22 | The Solution
23 | ------------
24 |
25 | This code works in *all* browsers, and it will always use the best communication mechanism possible.
26 |
27 | .. sourcecode:: html
28 |
29 |
30 |
31 |
32 | .. sourcecode:: javascript
33 |
34 | Orbited2.WebSocket.install({
35 | protocolVersion: "hixie76",
36 | })
37 |
38 | var ws = new WebSocket('ws://example.com/app')
39 |
40 |
41 | Orbited Veterans
42 | ----------------
43 |
44 | For all of you Orbited veterans who aren't so sure about writing WebSocket servers, and you just want to keep using trusty old Orbited.TCPSocket (but with performance and usability improvments) -- don't worry!
45 |
46 | .. sourcecode:: html
47 |
48 |
49 |
50 |
51 | .. sourcecode:: javascript
52 |
53 | var sock = new Orbited2.TCPSocket({ orbitedUri: "http://127.0.0.1:8000" })
54 | sock.open("irc.freenode.org", 6667);
55 | sock.onopen = function() {
56 | sock.send('NICK mcarter\r\n');
57 | }
58 | //etc
59 |
60 |
61 | Installation
62 | ============
63 |
64 | Orbited2 is written in python and depends on setuptools for installation. The easiest way to install Orbited2 is to type:
65 |
66 | .. sourcecode:: none
67 |
68 | # easy_install orbited2
69 |
70 |
71 | If you are missing python or setuptools, please refer to the following links:
72 |
73 | * `install python `_
74 | * `install setuptools `_
75 |
76 | To confirm your installation succeeded, type:
77 |
78 | .. sourcecode:: none
79 |
80 | # orbited2 --help
81 |
82 | Github
83 | ======
84 |
85 | The development version of Orbited2 is located on github:
86 |
87 | * http://github.com/mcarter/orbited2
88 |
89 | You can get a copy of the latest source by cloning the repository:
90 |
91 | .. sourcecode:: none
92 |
93 | # git clone git://github.com/mcarter/orbited2.git
94 |
95 |
96 | To install Orbited2 from source, ensure you have python and setuptools, then run:
97 |
98 |
99 | .. sourcecode:: none
100 |
101 | # cd orbited2/daemon
102 | # python setup.py install
103 |
--------------------------------------------------------------------------------
/example_orbited2.cfg:
--------------------------------------------------------------------------------
1 | # Listen
2 | RemoteDestination(
3 | name="ws_echo",
4 | hostname="127.0.0.1",
5 | port=8013,
6 | host_header = '*',
7 | protocol="ws/hixie76"
8 | )
9 |
10 | RemoteDestination(
11 | name="echo",
12 | hostname="127.0.0.1",
13 | port=8014,
14 | host_header = '*',
15 | protocol="tcp"
16 | )
17 |
18 | Listen (
19 | port=8000,
20 | protocols=['ws', 'csp'],
21 | interface="0.0.0.0"
22 | )
23 |
24 |
25 | # Access Control
26 |
27 |
--------------------------------------------------------------------------------
/site/docs:
--------------------------------------------------------------------------------
1 | ../docs/build/html/
--------------------------------------------------------------------------------
/site/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Orbited - Networking for the Web
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
Orbited: Real-time communication for the browser
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
Orbited provides a pure JavaScript/HTML socket in the browser. It is a web router and firewall that allows you to integrate web applications with arbitrary back-end systems. You can implement any network protocol in the browser - without resorting to plugins.
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Integration
68 |
69 | Orbited ships with support for many protocols out of the box, including IRC, XMPP, and STOMP (ActiveMQ, RabbitMQ)
70 |
71 |
72 |
73 |
74 |
75 | Scalability
76 |
77 | Orbited's shared-nothing architecture supports arbitrarily large server clusters - perfect horizontal scalability.
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | Usability
88 |
89 | Orbited works in all browsers, cross-port and cross-subdomain, with no loading bars, clicks, or spurious history entries.
90 |
91 |
92 |
93 |
94 |
95 | Standards
96 |
97 | Orbited uses only web standards to provide the most future-proof API and implementation.
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/site/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/site/logo.png
--------------------------------------------------------------------------------
/site/orbited_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/site/orbited_architecture.png
--------------------------------------------------------------------------------
/site/orbited_old_site.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/play-co/orbited2/dded31438111bb7bad818f27ca80a115feec172e/site/orbited_old_site.png
--------------------------------------------------------------------------------
/tests/browser/Orbited2.js:
--------------------------------------------------------------------------------
1 | ../../daemon/orbited2/static/Orbited2.js
--------------------------------------------------------------------------------
/tests/browser/Orbited2_raw.js:
--------------------------------------------------------------------------------
1 | ../../daemon/orbited2/js_src/Orbited2.js
--------------------------------------------------------------------------------
/tests/browser/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
36 |
37 |
38 | Orbited.Websocket test page
39 |
--------------------------------------------------------------------------------
/tests/browser/index_compiled.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
23 |
24 |
25 | Orbited.Websocket test page
26 |
--------------------------------------------------------------------------------
/tests/browser/jsio:
--------------------------------------------------------------------------------
1 | ../../../js.io/packages/
--------------------------------------------------------------------------------
/tests/browser/tcp_socket.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
29 |
30 |
31 | Orbited.Websocket test page
32 |
--------------------------------------------------------------------------------
/tests/browser/tcp_socket_compiled.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 | Orbited.Websocket test page
24 |
--------------------------------------------------------------------------------
/tests/servers/eventlet/start.py:
--------------------------------------------------------------------------------
1 | import eventlet
2 | from eventlet import wsgi
3 | from eventlet import websocket
4 | import static
5 | from paste.urlmap import URLMap
6 |
7 | # demo app
8 | import os
9 | import random
10 |
11 | @websocket.WebSocketWSGI
12 | def handle(ws):
13 | """ This is the websocket handler function. Note that we
14 | can dispatch based on path in here, too."""
15 | print 'HANDLE!', ws.path
16 | while True:
17 | print 'calling ws.wait'
18 | m = ws.wait()
19 | print 'GOT', m
20 | if m is None:
21 | break
22 | for i in range(3):
23 | ws.send(str(i+1) + ": " + m)
24 |
25 |
26 | def listen_tcp():
27 | def handle(client):
28 | while True:
29 | data = client.recv(1024)
30 | if not data: break
31 | for i in range(20):
32 | client.sendall(str(i) + ': ' + data)
33 | server = eventlet.listen(('localhost', 8014))
34 | print "Now listening echo:8014"
35 | pool = eventlet.GreenPool(10000)
36 |
37 | while True:
38 | new_sock, address = server.accept()
39 | pool.spawn_n(handle, new_sock)
40 |
41 | def main():
42 | app = URLMap()
43 | app['/echo'] = handle
44 | static_path = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'static')
45 | app['/'] = static.Cling(static_path)
46 |
47 | # run an example app from the command line
48 | listener = eventlet.listen(('localhost', 8013))
49 | print "\nListening http://localhost:8013/ in your websocket-capable browser.\n"
50 | eventlet.spawn(listen_tcp)
51 | wsgi.server(listener, app)
52 |
53 | if __name__ == "__main__":
54 | main()
--------------------------------------------------------------------------------
/tests/servers/eventlet/static:
--------------------------------------------------------------------------------
1 | ../../browser
--------------------------------------------------------------------------------