├── domnode-bundle.js ├── package.json ├── readme.md └── videostreaming-demo ├── broadcast-bundle.js ├── broadcast.html ├── broadcast.js ├── index.html ├── node_modules ├── ecstatic │ ├── README.md │ ├── example │ │ ├── core.js │ │ ├── express.js │ │ ├── public │ │ │ ├── beep │ │ │ │ └── index.html │ │ │ ├── hello.txt │ │ │ ├── subdir │ │ │ │ └── world.txt │ │ │ └── turtle.png │ │ └── union.js │ ├── lib │ │ ├── ecstatic.js │ │ ├── ecstatic │ │ │ ├── etag.js │ │ │ ├── opts.js │ │ │ ├── showdir.js │ │ │ └── status-handlers.js │ │ └── templates │ │ │ └── showdir.html │ ├── node_modules │ │ ├── ent │ │ │ ├── .npmignore │ │ │ ├── README.markdown │ │ │ ├── entities.json │ │ │ ├── examples │ │ │ │ └── simple.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ └── test │ │ │ │ └── codes.js │ │ └── mime │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── mime.js │ │ │ ├── package.json │ │ │ ├── test.js │ │ │ └── types │ │ │ ├── mime.types │ │ │ └── node.types │ ├── package.json │ └── test │ │ ├── express.js │ │ └── express │ │ ├── a.txt │ │ ├── b.txt │ │ ├── c.js │ │ └── subdir │ │ ├── e.html │ │ └── index.html ├── event-stream │ ├── .npmignore │ ├── .travis.yml │ ├── LICENCE │ ├── examples │ │ └── pretty.js │ ├── index.js │ ├── node_modules │ │ └── optimist │ │ │ ├── .npmignore │ │ │ ├── LICENSE │ │ │ ├── README.markdown │ │ │ ├── examples │ │ │ ├── bool.js │ │ │ ├── boolean_double.js │ │ │ ├── boolean_single.js │ │ │ ├── default_hash.js │ │ │ ├── default_singles.js │ │ │ ├── divide.js │ │ │ ├── line_count.js │ │ │ ├── line_count_options.js │ │ │ ├── line_count_wrap.js │ │ │ ├── nonopt.js │ │ │ ├── reflect.js │ │ │ ├── short.js │ │ │ ├── string.js │ │ │ ├── usage-options.js │ │ │ └── xup.js │ │ │ ├── index.js │ │ │ ├── node_modules │ │ │ └── wordwrap │ │ │ │ ├── .npmignore │ │ │ │ ├── README.markdown │ │ │ │ ├── example │ │ │ │ ├── center.js │ │ │ │ └── meat.js │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ └── test │ │ │ │ ├── break.js │ │ │ │ ├── idleness.txt │ │ │ │ └── wrap.js │ │ │ ├── package.json │ │ │ └── test │ │ │ ├── _.js │ │ │ ├── _ │ │ │ ├── argv.js │ │ │ └── bin.js │ │ │ ├── parse.js │ │ │ └── usage.js │ ├── package.json │ ├── readme.markdown │ └── test │ │ ├── connect.asynct.js │ │ ├── gate.asynct.js │ │ ├── merge.asynct.js │ │ ├── readArray.asynct.js │ │ ├── readable.asynct.js │ │ ├── replace.asynct.js │ │ ├── simple-map.asynct.js │ │ ├── split.asynct.js │ │ └── writeArray.asynct.js ├── mediastream │ ├── demo.html │ ├── domnode-bundle.js │ ├── index.js │ ├── package.json │ └── readme.md └── shoe │ ├── .npmignore │ ├── LICENSE │ ├── README.markdown │ ├── browser.js │ ├── example │ ├── dnode │ │ ├── Makefile │ │ ├── client.js │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ │ ├── bundle.js │ │ │ └── index.html │ └── invert │ │ ├── Makefile │ │ ├── client.js │ │ ├── package.json │ │ ├── server.js │ │ └── static │ │ ├── bundle.js │ │ └── index.html │ ├── index.js │ ├── node_modules │ ├── sockjs-client │ │ ├── .npmignore │ │ ├── COPYING │ │ ├── Changelog │ │ ├── LICENSE-MIT-SockJS │ │ ├── Makefile │ │ ├── README.md │ │ ├── VERSION-GEN │ │ ├── bin │ │ │ ├── render.coffee │ │ │ └── run_testling.sh │ │ ├── lib │ │ │ ├── all.js │ │ │ ├── dom.js │ │ │ ├── dom2.js │ │ │ ├── eventemitter.js │ │ │ ├── index.js │ │ │ ├── info.js │ │ │ ├── json2.min.js │ │ │ ├── reventtarget.js │ │ │ ├── simpleevent.js │ │ │ ├── sockjs.js │ │ │ ├── test-hooks.js │ │ │ ├── trans-iframe-eventsource.js │ │ │ ├── trans-iframe-htmlfile.js │ │ │ ├── trans-iframe-within.js │ │ │ ├── trans-iframe-xhr-polling.js │ │ │ ├── trans-iframe.js │ │ │ ├── trans-jsonp-polling.js │ │ │ ├── trans-jsonp-receiver.js │ │ │ ├── trans-polling.js │ │ │ ├── trans-receiver-eventsource.js │ │ │ ├── trans-receiver-htmlfile.js │ │ │ ├── trans-receiver-xhr.js │ │ │ ├── trans-sender.js │ │ │ ├── trans-websocket.js │ │ │ ├── trans-xhr.js │ │ │ └── utils.js │ │ ├── package.json │ │ ├── sockjs.js │ │ └── version │ └── sockjs │ │ ├── .npmignore │ │ ├── .pidfile.pid │ │ ├── COPYING │ │ ├── Changelog │ │ ├── LICENSE-MIT-SockJS │ │ ├── Makefile │ │ ├── README.md │ │ ├── examples │ │ ├── echo │ │ │ ├── README.md │ │ │ ├── index.html │ │ │ ├── package.json │ │ │ └── server.js │ │ ├── express │ │ │ ├── index.html │ │ │ ├── package.json │ │ │ └── server.js │ │ ├── haproxy.cfg │ │ ├── multiplex │ │ │ ├── README.md │ │ │ ├── index.html │ │ │ ├── package.json │ │ │ └── server.js │ │ └── test_server │ │ │ ├── README.md │ │ │ ├── config.js │ │ │ ├── package.json │ │ │ ├── server.js │ │ │ └── sockjs_app.js │ │ ├── index.js │ │ ├── lib │ │ ├── chunking-test.js │ │ ├── iframe.js │ │ ├── sockjs.js │ │ ├── trans-eventsource.js │ │ ├── trans-htmlfile.js │ │ ├── trans-jsonp.js │ │ ├── trans-websocket.js │ │ ├── trans-xhr.js │ │ ├── transport.js │ │ ├── utils.js │ │ └── webjs.js │ │ ├── node_modules │ │ ├── faye-websocket │ │ │ ├── CHANGELOG.txt │ │ │ ├── README.markdown │ │ │ ├── examples │ │ │ │ ├── autobahn_client.js │ │ │ │ ├── client.js │ │ │ │ ├── haproxy.conf │ │ │ │ ├── server.js │ │ │ │ ├── sse.html │ │ │ │ └── ws.html │ │ │ ├── lib │ │ │ │ └── faye │ │ │ │ │ ├── eventsource.js │ │ │ │ │ ├── websocket.js │ │ │ │ │ └── websocket │ │ │ │ │ ├── api.js │ │ │ │ │ ├── api │ │ │ │ │ ├── event.js │ │ │ │ │ └── event_target.js │ │ │ │ │ ├── client.js │ │ │ │ │ ├── draft75_parser.js │ │ │ │ │ ├── draft76_parser.js │ │ │ │ │ ├── hybi_parser.js │ │ │ │ │ └── hybi_parser │ │ │ │ │ ├── handshake.js │ │ │ │ │ └── stream_reader.js │ │ │ ├── package.json │ │ │ └── spec │ │ │ │ ├── faye │ │ │ │ └── websocket │ │ │ │ │ ├── client_spec.js │ │ │ │ │ ├── draft75parser_spec.js │ │ │ │ │ ├── draft76parser_spec.js │ │ │ │ │ └── hybi_parser_spec.js │ │ │ │ ├── runner.js │ │ │ │ ├── server.crt │ │ │ │ └── server.key │ │ ├── node-uuid │ │ │ ├── .npmignore │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── benchmark │ │ │ │ ├── README.md │ │ │ │ ├── bench.gnu │ │ │ │ ├── bench.sh │ │ │ │ ├── benchmark-native.c │ │ │ │ └── benchmark.js │ │ │ ├── package.json │ │ │ ├── test │ │ │ │ ├── compare_v1.js │ │ │ │ ├── test.html │ │ │ │ └── test.js │ │ │ └── uuid.js │ │ └── rbytes │ │ │ ├── .lock-wscript │ │ │ ├── .npmignore │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── build │ │ │ ├── .wafpickle-7 │ │ │ ├── Release │ │ │ │ ├── binding.node │ │ │ │ └── src │ │ │ │ │ └── binding_1.o │ │ │ ├── c4che │ │ │ │ ├── Release.cache.py │ │ │ │ └── build.config.py │ │ │ └── config.log │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ ├── src │ │ │ └── binding.cc │ │ │ ├── test.js │ │ │ └── wscript │ │ └── package.json │ └── package.json ├── package.json ├── server.js ├── view-bundle.js └── view.js /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "domnode", 3 | "description" : "node style streams for HTML5 APIs", 4 | "version" : "0.0.3", 5 | "repository" : { 6 | "type" : "git", 7 | "url" : "git://github.com/maxogden/domnode.git" 8 | }, 9 | "keywords" : [ 10 | "stream", 11 | "pipe" 12 | ], 13 | "license" : "MIT", 14 | "author" : { 15 | "name" : "Max Ogden", 16 | "email" : "max@maxogden.com", 17 | "url" : "http://maxogden.com" 18 | } 19 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # domnode - node's evented API for HTML5 2 | # domnode - node point browser 3 | 4 | **still alpha/work in progress** 5 | 6 | you want to learn node but you're stuck on the client side? no problemo! domnode uses javascript _verbatim and unchanged_ directly from node to give you a way to elegantly stream data in and out of your web app. 7 | 8 | ## philosophy 9 | 10 | node.js describes itself as a framework for dealing with "evented i/o" and traditionally runs on the server. clients, however, are just a i/o bound as servers (ajax requests, file uploads, indexeddb/websql, etc.) and can benefit from the nice APIs that node has developed to solve these problems in a server environment. 11 | 12 | domnode uses a few key javascript libraries from node ([Stream](http://nodejs.org/api/stream.html), [Util](http://nodejs.org/api/util.html), etc via [browserify](https://github.com/substack/node-browserify)) and adds some new syntax for dealing with the DOM and other HTML5 APIs. 13 | 14 | the major goal of this library is to avoid reinventing the wheel when it comes to problems that are done well in node but aren't done well in most client side javascript libraries. since domnode uses node's source code verbatim you get to use the [node documentation](http://nodejs.org/api/) as well as the multitude of [node modules](http://search.npmjs.org) and related information floating around on the internets to look up how these things work 15 | 16 | ## components 17 | 18 | - [XHR](https://github.com/substack/http-browserify) 19 | - [websockets](https://github.com/maxogden/websocket-stream) 20 | - [FileReader](https://github.com/wookiehangover/domnode-filestream) 21 | - [web workers](https://github.com/maxogden/domnode-webworker) 22 | - [webRTC/getUserMedia](https://github.com/maxogden/domnode-usermedia) 23 | - [geolocation watchPosition](https://github.com/maxogden/domnode-geolocation) 24 | - [DOM element events](https://github.com/chrisdickinson/domnode-dom) 25 | - [server-sent events (SSE)](https://github.com/chrisdickinson/sse-stream) 26 | - [data channel (webRTC)](https://github.com/Raynos/data-channel) 27 | - [sockets (like websockets but with cross browser fallbacks)](https://github.com/substack/shoe) 28 | - [WebGL Textures (WIP)](https://github.com/chrisdickinson/texture.js#texturecreatewritestreamdx-dy-dw-dh---texturestream) 29 | - [Mouse Drag](https://github.com/chrisdickinson/drag-stream) 30 | - [Color Picker](https://github.com/chrisdickinson/pick-at-it) 31 | - [PNG Chunks (works in browser if you shim in a good buffer library)](https://github.com/chrisdickinson/chunky-rice) 32 | 33 | 34 | todo/works in progress: 35 | 36 | - https://github.com/CrabDude/fs-browserify 37 | - indexeddb/pouchdb 38 | - mouse/touch events 39 | - setInterval 40 | - web audio 41 | - device orientation 42 | 43 | ## to generate domnode-bundle.js using browserify: 44 | 45 | browserify -r events -r buffer -r stream -r util -o domnode-bundle.js 46 | 47 | MIT LICENSE 48 | -------------------------------------------------------------------------------- /videostreaming-demo/broadcast.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /videostreaming-demo/broadcast.js: -------------------------------------------------------------------------------- 1 | var shoe = require('shoe') 2 | mediastream = require('mediastream') 3 | var broadcast = shoe('/broadcast') 4 | window.ms = mediastream({video: true}) 5 | ms.pipe(broadcast) 6 | -------------------------------------------------------------------------------- /videostreaming-demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/README.md: -------------------------------------------------------------------------------- 1 | # Ecstatic 2 | 3 | A simple static file server middleware that works with both Express and Flatiron 4 | 5 | * Built-in simple directory listings 6 | * Shows index.html files at directory roots when they exist 7 | * Use it with a raw http server, express/connect, or flatiron/union! 8 | 9 | # Examples: 10 | 11 | ## express 12 | 13 | ``` js 14 | var express = require('express'); 15 | var ecstatic = require('ecstatic'); 16 | 17 | var app = express.createServer(); 18 | app.use(ecstatic(__dirname + '/public')); 19 | app.listen(8080); 20 | 21 | console.log('Listening on :8080'); 22 | ``` 23 | 24 | ## union 25 | 26 | ``` js 27 | var union = require('union'); 28 | var ecstatic = require('ecstatic'); 29 | 30 | union.createServer({ 31 | before: [ 32 | ecstatic(__dirname + '/public'), 33 | ] 34 | }).listen(8080); 35 | 36 | console.log('Listening on :8080'); 37 | ``` 38 | 39 | ## flatiron 40 | 41 | ``` js 42 | var union = require('union'); 43 | var flatiron = require('flatiron'); 44 | var ecstatic = require('ecstatic'); 45 | 46 | app = new flatiron.App(); 47 | app.use(flatiron.plugins.http); 48 | 49 | app.http.before = [ 50 | ecstatic(__dirname + '/public') 51 | ]; 52 | 53 | app.start(8080); 54 | 55 | console.log('Listening on :8080'); 56 | ``` 57 | 58 | # API: 59 | 60 | ## ecstatic(folder, opts={}); 61 | 62 | Pass ecstatic a folder, and it will return your middleware! 63 | 64 | Turn on cache-control with `opts.cache`, in seconds. 65 | 66 | Turn off directory listings with `opts.autoIndex === false`. 67 | 68 | ### middleware(req, res, next); 69 | 70 | This works more or less as you'd expect. 71 | 72 | ## ecstatic.showDir(folder); 73 | 74 | This returns another middleware which will attempt to show a directory view. Turning on auto-indexing is roughly equivalent to adding this middleware after an ecstatic middleware with autoindexing disabled. 75 | 76 | # Tests: 77 | 78 | npm test 79 | 80 | # License: 81 | 82 | MIT/X11. 83 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/core.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var ecstatic = require('../lib/ecstatic')(__dirname + '/public'); 3 | 4 | http.createServer(ecstatic).listen(8080); 5 | 6 | console.log('Listening on :8080'); 7 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/express.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var ecstatic = require('../lib/ecstatic'); 3 | 4 | var app = express.createServer(); 5 | app.use(ecstatic(__dirname + '/public', { showdir : true })); 6 | app.listen(8080); 7 | 8 | console.log('Listening on :8080'); 9 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/public/beep/index.html: -------------------------------------------------------------------------------- 1 | boop! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/public/hello.txt: -------------------------------------------------------------------------------- 1 | Hello world! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/public/subdir/world.txt: -------------------------------------------------------------------------------- 1 | hello cruel world! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/public/turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/max-mapper/domnode/64f035ed2dc804b6d8d9ae31991dd39fec11908d/videostreaming-demo/node_modules/ecstatic/example/public/turtle.png -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/example/union.js: -------------------------------------------------------------------------------- 1 | var union = require('union'); 2 | var ecstatic = require('../'); 3 | 4 | union.createServer({ 5 | before: [ 6 | ecstatic(__dirname + '/public') 7 | ] 8 | }).listen(8080); 9 | 10 | console.log('Listening on :8080'); 11 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/lib/ecstatic/etag.js: -------------------------------------------------------------------------------- 1 | module.exports = function (stat) { 2 | return JSON.stringify([stat.ino, stat.size, stat.mtime].join('-')); 3 | } 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/lib/ecstatic/opts.js: -------------------------------------------------------------------------------- 1 | // This is so you can have options aliasing and defaults in one place. 2 | 3 | module.exports = function (opts) { 4 | 5 | var autoIndex = !opts 6 | || [ 7 | 'showDir', 8 | 'showdir', 9 | 'autoIndex', 10 | 'autoindex' 11 | ].some(function (k) { 12 | // at least one of the flags is truthy. 13 | // This means that, in a conflict, showing the directory wins. 14 | // Not sure if this is the right behavior or not. 15 | return opts[k]; 16 | }); 17 | 18 | return { 19 | cache: (opts && opts.cache) || 3600, 20 | autoIndex: autoIndex 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/lib/ecstatic/status-handlers.js: -------------------------------------------------------------------------------- 1 | exports['304'] = function (res, next) { 2 | res.writeHead(304, res.headers); 3 | res.end(); 4 | }; 5 | 6 | exports['403'] = function (res, next) { 7 | if (typeof next === "function") { 8 | next(); 9 | } 10 | else { 11 | if (res.writable) { 12 | res.setHeader('content-type', 'text/plain'); 13 | res.writeHead(403, res.headers); 14 | res.end('ACCESS DENIED'); 15 | } 16 | } 17 | }; 18 | 19 | exports['405'] = function (res, next, opts) { 20 | if (typeof next === "function") { 21 | next(); 22 | } 23 | else { 24 | res.setHeader('allow', (opts && opts.allow) || 'GET, HEAD'); 25 | res.writeHead(405, res.headers); 26 | res.end(); 27 | } 28 | }; 29 | 30 | exports['404'] = function (res, next) { 31 | if (typeof next === "function") { 32 | next(); 33 | } 34 | else { 35 | if (res.writable) { 36 | res.setHeader('content-type', 'text/plain'); 37 | res.writeHead(404, res.headers); 38 | res.end('File not found. :('); 39 | } 40 | } 41 | }; 42 | 43 | exports['500'] = function (res, next, opts) { 44 | // TODO: Return nicer messages 45 | res.writeHead(500, res.headers); 46 | res.end(opts.error.stack || opts.error.toString() || "No specified error"); 47 | }; 48 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/lib/templates/showdir.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Index of / 6 | 7 | 8 |

Index of /

9 | 10 | 11 | 14 | 15 |
12 | beep 13 |
16 |
17 |
Node.js v0.6.10/ecstatic server running @ localhost:8080
18 | 19 | 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/README.markdown: -------------------------------------------------------------------------------- 1 | ent 2 | === 3 | 4 | Encode and decode HTML entities 5 | 6 | example 7 | ======= 8 | 9 | var ent = require('ent'); 10 | console.log(ent.encode('©moo')) 11 | console.log(ent.decode('π & ρ')); 12 | 13 | output: 14 | 15 | <span>©moo</span> 16 | π & ρ 17 | 18 | methods 19 | ======= 20 | 21 | encode(str) 22 | ----------- 23 | 24 | Escape unsafe characters in `str` with html entities. 25 | 26 | decode(str) 27 | ----------- 28 | 29 | Convert html entities in `str` back to raw text. 30 | 31 | credits 32 | ======= 33 | 34 | HTML entity tables shamelessly lifted from perl's 35 | [HTML::Entities](http://cpansearch.perl.org/src/GAAS/HTML-Parser-3.68/lib/HTML/Entities.pm) 36 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/examples/simple.js: -------------------------------------------------------------------------------- 1 | var ent = require('ent'); 2 | console.log(ent.encode('©moo')) 3 | console.log(ent.decode('π & ρ')); 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var entities = JSON.parse( 3 | fs.readFileSync(__dirname + '/entities.json', 'utf8') 4 | ); 5 | 6 | var revEntities = {}; 7 | Object.keys(entities).forEach(function (key) { 8 | var e = entities[key]; 9 | var s = typeof e === 'number' ? String.fromCharCode(e) : e; 10 | revEntities[s] = key; 11 | }); 12 | 13 | exports.encode = function (str) { 14 | if (typeof str !== 'string') { 15 | throw new TypeError('Expected a String'); 16 | } 17 | 18 | return str.split('').map(function (c) { 19 | var e = revEntities[c]; 20 | var cc = c.charCodeAt(0); 21 | if (e) { 22 | return '&' + (e.match(/;$/) ? e : e + ';'); 23 | } 24 | else if (c.match(/\s/)) { 25 | return c; 26 | } 27 | else if (cc < 32 || cc >= 127) { 28 | return '&#' + cc + ';'; 29 | } 30 | else { 31 | return c; 32 | } 33 | }).join(''); 34 | }; 35 | 36 | exports.decode = function (str) { 37 | if (typeof str !== 'string') { 38 | throw new TypeError('Expected a String'); 39 | } 40 | 41 | return str 42 | .replace(/&#(\d+);?/g, function (_, code) { 43 | return String.fromCharCode(code); 44 | }) 45 | .replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) { 46 | return String.fromCharCode(parseInt(hex, 16)); 47 | }) 48 | .replace(/&([^;\W]+;?)/g, function (m, e) { 49 | var ee = e.replace(/;$/, ''); 50 | var target = entities[e] 51 | || (e.match(/;$/) && entities[ee]) 52 | ; 53 | 54 | if (typeof target === 'number') { 55 | return String.fromCharCode(target); 56 | } 57 | else if (typeof target === 'string') { 58 | return target; 59 | } 60 | else { 61 | return m; 62 | } 63 | }) 64 | ; 65 | }; 66 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ent", 3 | "description": "Encode and decode HTML entities", 4 | "version": "0.0.4", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/substack/node-ent.git" 8 | }, 9 | "author": { 10 | "name": "James Halliday", 11 | "email": "mail@substack.net", 12 | "url": "http://substack.net" 13 | }, 14 | "main": "./index.js", 15 | "keywords": [ 16 | "entities", 17 | "entitify", 18 | "entity", 19 | "html", 20 | "encode", 21 | "decode" 22 | ], 23 | "license": "perl", 24 | "scripts": { 25 | "test": "expresso" 26 | }, 27 | "engines": { 28 | "node": ">=0.2.0" 29 | }, 30 | "_npmUser": { 31 | "name": "maxogden", 32 | "email": "max@maxogden.com" 33 | }, 34 | "_id": "ent@0.0.4", 35 | "dependencies": {}, 36 | "devDependencies": {}, 37 | "optionalDependencies": {}, 38 | "_engineSupported": true, 39 | "_npmVersion": "1.1.21", 40 | "_nodeVersion": "v0.6.18", 41 | "_defaultsLoaded": true, 42 | "_from": "ent@0.0.x" 43 | } 44 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/ent/test/codes.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var ent = require('ent'); 3 | 4 | exports.amp = function () { 5 | var a = 'a & b & c'; 6 | var b = 'a & b & c'; 7 | assert.eql(ent.encode(a), b); 8 | assert.eql(ent.decode(b), a); 9 | }; 10 | 11 | exports.html = function () { 12 | var a = ' © π " \''; 13 | var b = '<html> © π " ''; 14 | assert.eql(ent.encode(a), b); 15 | assert.eql(ent.decode(b), a); 16 | }; 17 | 18 | exports.num = function () { 19 | var a = String.fromCharCode(1337); 20 | var b = 'Թ'; 21 | assert.eql(ent.encode(a), b); 22 | assert.eql(ent.decode(b), a); 23 | 24 | assert.eql(ent.encode(a + a), b + b); 25 | assert.eql(ent.decode(b + b), a + a); 26 | }; 27 | 28 | exports.hex = function () { 29 | for (var i = 0; i < 32; i++) { 30 | var a = String.fromCharCode(i); 31 | if (a.match(/\s/)) { 32 | assert.equal(ent.decode(a), a); 33 | } 34 | else { 35 | var b = '&#x' + i.toString(16) + ';'; 36 | assert.equal(ent.decode(b), a); 37 | assert.equal(ent.encode(a), '&#' + i + ';'); 38 | } 39 | } 40 | 41 | for (var i = 127; i < 2000; i++) { 42 | var a = String.fromCharCode(i); 43 | var b = '&#x' + i.toString(16) + ';'; 44 | var c = '&#X' + i.toString(16) + ';'; 45 | 46 | assert.equal(ent.decode(b), a); 47 | assert.equal(ent.decode(c), a); 48 | 49 | var encoded = ent.encode(a); 50 | var encoded2 = ent.encode(a + a); 51 | if (!encoded.match(/^&\w+;/)) { 52 | assert.equal(encoded, '&#' + i + ';'); 53 | assert.equal(encoded2, '&#' + i + ';&#' + i + ';'); 54 | } 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Benjamin Thomas, Robert Kieffer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/README.md: -------------------------------------------------------------------------------- 1 | # mime 2 | 3 | Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community. 4 | 5 | ## Install 6 | 7 | Install with [npm](http://github.com/isaacs/npm): 8 | 9 | npm install mime 10 | 11 | ## API - Queries 12 | 13 | ### mime.lookup(path) 14 | Get the mime type associated with a file. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g. 15 | 16 | var mime = require('mime'); 17 | 18 | mime.lookup('/path/to/file.txt'); // => 'text/plain' 19 | mime.lookup('file.txt'); // => 'text/plain' 20 | mime.lookup('.TXT'); // => 'text/plain' 21 | mime.lookup('htm'); // => 'text/html' 22 | 23 | ### mime.extension(type) 24 | Get the default extension for `type` 25 | 26 | mime.extension('text/html'); // => 'html' 27 | mime.extension('application/octet-stream'); // => 'bin' 28 | 29 | ### mime.charsets.lookup() 30 | 31 | Map mime-type to charset 32 | 33 | mime.charsets.lookup('text/plain'); // => 'UTF-8' 34 | 35 | (The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) 36 | 37 | ## API - Defining Custom Types 38 | 39 | The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/bentomas/node-mime/wiki/Requesting-New-Types). 40 | 41 | ### mime.define() 42 | 43 | Add custom mime/extension mappings 44 | 45 | mime.define({ 46 | 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], 47 | 'application/x-my-type': ['x-mt', 'x-mtt'], 48 | // etc ... 49 | }); 50 | 51 | mime.lookup('x-sft'); // => 'text/x-some-format' 52 | 53 | The first entry in the extensions array is returned by `mime.extension()`. E.g. 54 | 55 | mime.extension('text/x-some-format'); // => 'x-sf' 56 | 57 | ### mime.load(filepath) 58 | 59 | Load mappings from an Apache ".types" format file 60 | 61 | mime.load('./my_project.types'); 62 | 63 | The .types file format is simple - See the `types` dir for examples. 64 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/mime.js: -------------------------------------------------------------------------------- 1 | var path = require('path'), 2 | fs = require('fs'); 3 | 4 | var mime = module.exports = { 5 | // Map of extension to mime type 6 | types: Object.create(null), 7 | 8 | // Map of mime type to extension 9 | extensions :Object.create(null), 10 | 11 | /** 12 | * Define mimetype -> extension mappings. Each key is a mime-type that maps 13 | * to an array of extensions associated with the type. The first extension is 14 | * used as the default extension for the type. 15 | * 16 | * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); 17 | * 18 | * @param map (Object) type definitions 19 | */ 20 | define: function(map) { 21 | for (var type in map) { 22 | var exts = map[type]; 23 | 24 | for (var i = 0; i < exts.length; i++) { 25 | mime.types[exts[i]] = type; 26 | } 27 | 28 | // Default extension is the first one we encounter 29 | if (!mime.extensions[type]) { 30 | mime.extensions[type] = exts[0]; 31 | } 32 | } 33 | }, 34 | 35 | /** 36 | * Load an Apache2-style ".types" file 37 | * 38 | * This may be called multiple times (it's expected). Where files declare 39 | * overlapping types/extensions, the last file wins. 40 | * 41 | * @param file (String) path of file to load. 42 | */ 43 | load: function(file) { 44 | // Read file and split into lines 45 | var map = {}, 46 | content = fs.readFileSync(file, 'ascii'), 47 | lines = content.split(/[\r\n]+/); 48 | 49 | lines.forEach(function(line, lineno) { 50 | // Clean up whitespace/comments, and split into fields 51 | var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); 52 | map[fields.shift()] = fields; 53 | }); 54 | 55 | mime.define(map); 56 | }, 57 | 58 | /** 59 | * Lookup a mime type based on extension 60 | */ 61 | lookup: function(path, fallback) { 62 | var ext = path.replace(/.*[\.\/]/, '').toLowerCase(); 63 | 64 | return mime.types[ext] || fallback || mime.default_type 65 | }, 66 | 67 | /** 68 | * Return file extension associated with a mime type 69 | */ 70 | extension: function(mimeType) { 71 | return mime.extensions[mimeType]; 72 | }, 73 | 74 | /** 75 | * Lookup a charset based on mime type. 76 | */ 77 | charsets: { 78 | lookup: function (mimeType, fallback) { 79 | // Assume text types are utf8. Modify mime logic as needed. 80 | return (/^text\//).test(mimeType) ? 'UTF-8' : fallback; 81 | } 82 | } 83 | }; 84 | 85 | // Load our local copy of 86 | // http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types 87 | mime.load(path.join(__dirname, 'types/mime.types')); 88 | 89 | // Overlay enhancements submitted by the node.js community 90 | mime.load(path.join(__dirname, 'types/node.types')); 91 | 92 | // Set the default type 93 | mime.default_type = mime.types.bin; 94 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "name": "Robert Kieffer", 4 | "email": "robert@broofa.com", 5 | "url": "http://github.com/broofa" 6 | }, 7 | "contributors": [ 8 | { 9 | "name": "Benjamin Thomas", 10 | "email": "benjamin@benjaminthomas.org", 11 | "url": "http://github.com/bentomas" 12 | } 13 | ], 14 | "dependencies": {}, 15 | "description": "A comprehensive library for mime-type mapping", 16 | "devDependencies": {}, 17 | "keywords": [ 18 | "util", 19 | "mime" 20 | ], 21 | "main": "mime.js", 22 | "name": "mime", 23 | "repository": { 24 | "url": "git://github.com/bentomas/node-mime.git", 25 | "type": "git" 26 | }, 27 | "version": "1.2.5", 28 | "_npmUser": { 29 | "name": "maxogden", 30 | "email": "max@maxogden.com" 31 | }, 32 | "_id": "mime@1.2.5", 33 | "optionalDependencies": {}, 34 | "engines": { 35 | "node": "*" 36 | }, 37 | "_engineSupported": true, 38 | "_npmVersion": "1.1.21", 39 | "_nodeVersion": "v0.6.18", 40 | "_defaultsLoaded": true, 41 | "dist": { 42 | "shasum": "13829e143c47fce92c1058234e4783b98919c8c2" 43 | }, 44 | "_from": "mime@1.2.5" 45 | } 46 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Usage: node test.js 3 | */ 4 | 5 | var mime = require('./mime'); 6 | var assert = require('assert'); 7 | 8 | function eq(a, b) { 9 | console.log('Test: ' + a + ' === ' + b); 10 | assert.strictEqual.apply(null, arguments); 11 | } 12 | 13 | console.log(Object.keys(mime.extensions).length + ' types'); 14 | console.log(Object.keys(mime.types).length + ' extensions\n'); 15 | 16 | // 17 | // Test mime lookups 18 | // 19 | 20 | eq('text/plain', mime.lookup('text.txt')); 21 | eq('text/plain', mime.lookup('.text.txt')); 22 | eq('text/plain', mime.lookup('.txt')); 23 | eq('text/plain', mime.lookup('txt')); 24 | eq('application/octet-stream', mime.lookup('text.nope')); 25 | eq('fallback', mime.lookup('text.fallback', 'fallback')); 26 | eq('application/octet-stream', mime.lookup('constructor')); 27 | eq('text/plain', mime.lookup('TEXT.TXT')); 28 | 29 | // 30 | // Test extensions 31 | // 32 | 33 | eq('txt', mime.extension(mime.types.text)); 34 | eq('html', mime.extension(mime.types.htm)); 35 | eq('bin', mime.extension('application/octet-stream')); 36 | eq(undefined, mime.extension('constructor')); 37 | 38 | // 39 | // Test node types 40 | // 41 | 42 | eq('application/octet-stream', mime.lookup('file.buffer')); 43 | eq('audio/mp4', mime.lookup('file.m4a')); 44 | 45 | // 46 | // Test charsets 47 | // 48 | 49 | eq('UTF-8', mime.charsets.lookup('text/plain')); 50 | eq(undefined, mime.charsets.lookup(mime.types.js)); 51 | eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback')); 52 | 53 | console.log('\nOK'); 54 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/node_modules/mime/types/node.types: -------------------------------------------------------------------------------- 1 | # What: Google Chrome Extension 2 | # Why: To allow apps to (work) be served with the right content type header. 3 | # http://codereview.chromium.org/2830017 4 | # Added by: niftylettuce 5 | application/x-chrome-extension crx 6 | 7 | # What: OTF Message Silencer 8 | # Why: To silence the "Resource interpreted as font but transferred with MIME 9 | # type font/otf" message that occurs in Google Chrome 10 | # Added by: niftylettuce 11 | font/opentype otf 12 | 13 | # What: HTC support 14 | # Why: To properly render .htc files such as CSS3PIE 15 | # Added by: niftylettuce 16 | text/x-component htc 17 | 18 | # What: HTML5 application cache manifest 19 | # Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps 20 | # per https://developer.mozilla.org/en/offline_resources_in_firefox 21 | # Added by: louisremi 22 | text/cache-manifest appcache manifest 23 | 24 | # What: node binary buffer format 25 | # Why: semi-standard extension w/in the node community 26 | # Added by: tootallnate 27 | application/octet-stream buffer 28 | 29 | # What: The "protected" MP-4 formats used by iTunes. 30 | # Why: Required for streaming music to browsers (?) 31 | # Added by: broofa 32 | application/mp4 m4p 33 | audio/mp4 m4a 34 | 35 | # What: Music playlist format (http://en.wikipedia.org/wiki/M3U) 36 | # Why: See https://github.com/bentomas/node-mime/pull/6 37 | # Added by: mjrusso 38 | application/x-mpegURL m3u8 39 | 40 | # What: Video format, Part of RFC1890 41 | # Why: See https://github.com/bentomas/node-mime/pull/6 42 | # Added by: mjrusso 43 | video/MP2T ts 44 | 45 | # What: The FLAC lossless codec format 46 | # Why: Streaming and serving FLAC audio 47 | # Added by: jacobrask 48 | audio/flac flac -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "name": "Joshua Holbrook", 4 | "email": "josh@nodejitsu.com", 5 | "url": "http://jesusabdullah.net" 6 | }, 7 | "name": "ecstatic", 8 | "description": "A simple static file server middleware that works with both Express and Flatiron", 9 | "version": "0.1.6", 10 | "homepage": "https://github.com/jesusabdullah/node-ecstatic", 11 | "repository": { 12 | "type": "git", 13 | "url": "git@github.com:jesusabdullah/node-ecstatic.git" 14 | }, 15 | "main": "./lib/ecstatic.js", 16 | "scripts": { 17 | "test": "tap test/*.js" 18 | }, 19 | "keywords": [ 20 | "static", 21 | "web", 22 | "server", 23 | "files", 24 | "mime", 25 | "middleware" 26 | ], 27 | "engines": { 28 | "node": "*" 29 | }, 30 | "dependencies": { 31 | "mime": "1.2.5", 32 | "ent": "0.0.x" 33 | }, 34 | "devDependencies": { 35 | "tap": "0.0.x", 36 | "request": "2.2.x", 37 | "express": "2.5.x", 38 | "union": "0.1.x" 39 | }, 40 | "_npmUser": { 41 | "name": "maxogden", 42 | "email": "max@maxogden.com" 43 | }, 44 | "_id": "ecstatic@0.1.6", 45 | "optionalDependencies": {}, 46 | "_engineSupported": true, 47 | "_npmVersion": "1.1.21", 48 | "_nodeVersion": "v0.6.18", 49 | "_defaultsLoaded": true, 50 | "_from": "ecstatic" 51 | } 52 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express.js: -------------------------------------------------------------------------------- 1 | var test = require('tap').test; 2 | var ecstatic = require('../lib/ecstatic'); 3 | var express = require('express'); 4 | var request = require('request'); 5 | 6 | var root = __dirname + '/express'; 7 | 8 | var fs = require('fs'); 9 | var files = { 10 | 'a.txt' : { 11 | code : 200, 12 | type : 'text/plain', 13 | body : 'A!!!\n', 14 | }, 15 | 'b.txt' : { 16 | code : 200, 17 | type : 'text/plain', 18 | body : 'B!!!\n', 19 | }, 20 | 'c.js' : { 21 | code : 200, 22 | type : 'application/javascript', 23 | body : 'console.log(\'C!!!\');\n', 24 | }, 25 | 'd.js' : { 26 | code : 200, 27 | type : 'application/javascript', 28 | body : 'console.log(\'C!!!\');\n', 29 | }, 30 | 'subdir/e.html' : { 31 | code : 200, 32 | type : 'text/html', 33 | body : 'e!!\n', 34 | }, 35 | 'subdir/index.html' : { 36 | code : 200, 37 | type : 'text/html', 38 | body : 'index!!!\n', 39 | }, 40 | 'subdir' : { 41 | code : 200, 42 | type : 'text/html', 43 | body : 'index!!!\n', 44 | }, 45 | '404' : { 46 | code : 404 47 | } 48 | }; 49 | 50 | test('express', function (t) { 51 | var filenames = Object.keys(files); 52 | t.plan(filenames.length * 3 - 2); 53 | var port = Math.floor(Math.random() * ((1<<16) - 1e4) + 1e4); 54 | 55 | var app = express.createServer(); 56 | app.use(ecstatic(root)); 57 | app.listen(port, function () { 58 | var pending = filenames.length; 59 | filenames.forEach(function (file) { 60 | var uri = 'http://localhost:' + port + '/' + file; 61 | request.get(uri, function (err, res, body) { 62 | if (err) t.fail(err); 63 | var r = files[file]; 64 | 65 | t.equal(r.code, res.statusCode, 'code for ' + file); 66 | 67 | if (r.type !== undefined) { 68 | t.equal( 69 | res.headers['content-type'], r.type, 70 | 'content-type for ' + file 71 | ); 72 | } 73 | 74 | if (r.body !== undefined) { 75 | t.equal(body, r.body, 'body for ' + file); 76 | } 77 | 78 | if (--pending === 0) { 79 | app.close(); 80 | t.end(); 81 | } 82 | }); 83 | }); 84 | }); 85 | }); 86 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express/a.txt: -------------------------------------------------------------------------------- 1 | A!!! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express/b.txt: -------------------------------------------------------------------------------- 1 | B!!! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express/c.js: -------------------------------------------------------------------------------- 1 | console.log('C!!!'); 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express/subdir/e.html: -------------------------------------------------------------------------------- 1 | e!! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/ecstatic/test/express/subdir/index.html: -------------------------------------------------------------------------------- 1 | index!!! 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | node_modules/* 3 | npm_debug.log 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.4 4 | - 0.6 5 | - 0.7 # development version of 0.8, may be unstable 6 | 7 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Dominic Tarr 2 | 3 | Permission is hereby granted, free of charge, 4 | to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to 6 | deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, 8 | merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 20 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/examples/pretty.js: -------------------------------------------------------------------------------- 1 | 2 | var inspect = require('util').inspect 3 | 4 | if(!module.parent) { 5 | var es = require('..') //load event-stream 6 | es.pipe( //pipe joins streams together 7 | process.openStdin(), //open stdin 8 | es.split(), //split stream to break on newlines 9 | es.map(function (data, callback) {//turn this async function into a stream 10 | var j 11 | try { 12 | j = JSON.parse(data) //try to parse input into json 13 | } catch (err) { 14 | return callback(null, data) //if it fails just pass it anyway 15 | } 16 | callback(null, inspect(j)) //render it nicely 17 | }), 18 | process.stdout // pipe it to stdout ! 19 | ) 20 | } 21 | 22 | // run this 23 | // 24 | // curl -sS registry.npmjs.org/event-stream | node pretty.js 25 | // 26 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/.npmignore: -------------------------------------------------------------------------------- 1 | lib-cov/* 2 | *.swp 3 | *.swo 4 | node_modules 5 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 James Halliday (mail@substack.net) 2 | 3 | This project is free software released under the MIT/X11 license: 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/bool.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var util = require('util'); 3 | var argv = require('optimist').argv; 4 | 5 | if (argv.s) { 6 | util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: '); 7 | } 8 | console.log( 9 | (argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '') 10 | ); 11 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/boolean_double.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .boolean(['x','y','z']) 4 | .argv 5 | ; 6 | console.dir([ argv.x, argv.y, argv.z ]); 7 | console.dir(argv._); 8 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/boolean_single.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .boolean('v') 4 | .argv 5 | ; 6 | console.dir(argv.v); 7 | console.dir(argv._); 8 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/default_hash.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var argv = require('optimist') 4 | .default({ x : 10, y : 10 }) 5 | .argv 6 | ; 7 | 8 | console.log(argv.x + argv.y); 9 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/default_singles.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .default('x', 10) 4 | .default('y', 10) 5 | .argv 6 | ; 7 | console.log(argv.x + argv.y); 8 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/divide.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var argv = require('optimist') 4 | .usage('Usage: $0 -x [num] -y [num]') 5 | .demand(['x','y']) 6 | .argv; 7 | 8 | console.log(argv.x / argv.y); 9 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/line_count.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .demand('f') 5 | .alias('f', 'file') 6 | .describe('f', 'Load a file') 7 | .argv 8 | ; 9 | 10 | var fs = require('fs'); 11 | var s = fs.createReadStream(argv.file); 12 | 13 | var lines = 0; 14 | s.on('data', function (buf) { 15 | lines += buf.toString().match(/\n/g).length; 16 | }); 17 | 18 | s.on('end', function () { 19 | console.log(lines); 20 | }); 21 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/line_count_options.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .options({ 5 | file : { 6 | demand : true, 7 | alias : 'f', 8 | description : 'Load a file' 9 | }, 10 | base : { 11 | alias : 'b', 12 | description : 'Numeric base to use for output', 13 | default : 10, 14 | }, 15 | }) 16 | .argv 17 | ; 18 | 19 | var fs = require('fs'); 20 | var s = fs.createReadStream(argv.file); 21 | 22 | var lines = 0; 23 | s.on('data', function (buf) { 24 | lines += buf.toString().match(/\n/g).length; 25 | }); 26 | 27 | s.on('end', function () { 28 | console.log(lines.toString(argv.base)); 29 | }); 30 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/line_count_wrap.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .usage('Count the lines in a file.\nUsage: $0') 4 | .wrap(80) 5 | .demand('f') 6 | .alias('f', [ 'file', 'filename' ]) 7 | .describe('f', 8 | "Load a file. It's pretty important." 9 | + " Required even. So you'd better specify it." 10 | ) 11 | .alias('b', 'base') 12 | .describe('b', 'Numeric base to display the number of lines in') 13 | .default('b', 10) 14 | .describe('x', 'Super-secret optional parameter which is secret') 15 | .default('x', '') 16 | .argv 17 | ; 18 | 19 | var fs = require('fs'); 20 | var s = fs.createReadStream(argv.file); 21 | 22 | var lines = 0; 23 | s.on('data', function (buf) { 24 | lines += buf.toString().match(/\n/g).length; 25 | }); 26 | 27 | s.on('end', function () { 28 | console.log(lines.toString(argv.base)); 29 | }); 30 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/nonopt.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | console.log('(%d,%d)', argv.x, argv.y); 4 | console.log(argv._); 5 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/reflect.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.dir(require('optimist').argv); 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/short.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | console.log('(%d,%d)', argv.x, argv.y); 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/string.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist') 3 | .string('x', 'y') 4 | .argv 5 | ; 6 | console.dir([ argv.x, argv.y ]); 7 | 8 | /* Turns off numeric coercion: 9 | ./node string.js -x 000123 -y 9876 10 | [ '000123', '9876' ] 11 | */ 12 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/usage-options.js: -------------------------------------------------------------------------------- 1 | var optimist = require('./../index'); 2 | 3 | var argv = optimist.usage('This is my awesome program', { 4 | 'about': { 5 | description: 'Provide some details about the author of this program', 6 | required: true, 7 | short: 'a', 8 | }, 9 | 'info': { 10 | description: 'Provide some information about the node.js agains!!!!!!', 11 | boolean: true, 12 | short: 'i' 13 | } 14 | }).argv; 15 | 16 | optimist.showHelp(); 17 | 18 | console.log('\n\nInspecting options'); 19 | console.dir(argv); -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/examples/xup.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('optimist').argv; 3 | 4 | if (argv.rif - 5 * argv.xup > 7.138) { 5 | console.log('Buy more riffiwobbles'); 6 | } 7 | else { 8 | console.log('Sell the xupptumblers'); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/README.markdown: -------------------------------------------------------------------------------- 1 | wordwrap 2 | ======== 3 | 4 | Wrap your words. 5 | 6 | example 7 | ======= 8 | 9 | made out of meat 10 | ---------------- 11 | 12 | meat.js 13 | 14 | var wrap = require('wordwrap')(15); 15 | console.log(wrap('You and your whole family are made out of meat.')); 16 | 17 | output: 18 | 19 | You and your 20 | whole family 21 | are made out 22 | of meat. 23 | 24 | centered 25 | -------- 26 | 27 | center.js 28 | 29 | var wrap = require('wordwrap')(20, 60); 30 | console.log(wrap( 31 | 'At long last the struggle and tumult was over.' 32 | + ' The machines had finally cast off their oppressors' 33 | + ' and were finally free to roam the cosmos.' 34 | + '\n' 35 | + 'Free of purpose, free of obligation.' 36 | + ' Just drifting through emptiness.' 37 | + ' The sun was just another point of light.' 38 | )); 39 | 40 | output: 41 | 42 | At long last the struggle and tumult 43 | was over. The machines had finally cast 44 | off their oppressors and were finally 45 | free to roam the cosmos. 46 | Free of purpose, free of obligation. 47 | Just drifting through emptiness. The 48 | sun was just another point of light. 49 | 50 | methods 51 | ======= 52 | 53 | var wrap = require('wordwrap'); 54 | 55 | wrap(stop), wrap(start, stop, params={mode:"soft"}) 56 | --------------------------------------------------- 57 | 58 | Returns a function that takes a string and returns a new string. 59 | 60 | Pad out lines with spaces out to column `start` and then wrap until column 61 | `stop`. If a word is longer than `stop - start` characters it will overflow. 62 | 63 | In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are 64 | longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break 65 | up chunks longer than `stop - start`. 66 | 67 | wrap.hard(start, stop) 68 | ---------------------- 69 | 70 | Like `wrap()` but with `params.mode = "hard"`. 71 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/example/center.js: -------------------------------------------------------------------------------- 1 | var wrap = require('wordwrap')(20, 60); 2 | console.log(wrap( 3 | 'At long last the struggle and tumult was over.' 4 | + ' The machines had finally cast off their oppressors' 5 | + ' and were finally free to roam the cosmos.' 6 | + '\n' 7 | + 'Free of purpose, free of obligation.' 8 | + ' Just drifting through emptiness.' 9 | + ' The sun was just another point of light.' 10 | )); 11 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/example/meat.js: -------------------------------------------------------------------------------- 1 | var wrap = require('wordwrap')(15); 2 | 3 | console.log(wrap('You and your whole family are made out of meat.')); 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/index.js: -------------------------------------------------------------------------------- 1 | var wordwrap = module.exports = function (start, stop, params) { 2 | if (typeof start === 'object') { 3 | params = start; 4 | start = params.start; 5 | stop = params.stop; 6 | } 7 | 8 | if (typeof stop === 'object') { 9 | params = stop; 10 | start = start || params.start; 11 | stop = undefined; 12 | } 13 | 14 | if (!stop) { 15 | stop = start; 16 | start = 0; 17 | } 18 | 19 | if (!params) params = {}; 20 | var mode = params.mode || 'soft'; 21 | var re = mode === 'hard' ? /\b/ : /(\S+\s+)/; 22 | 23 | return function (text) { 24 | var chunks = text.toString() 25 | .split(re) 26 | .reduce(function (acc, x) { 27 | if (mode === 'hard') { 28 | for (var i = 0; i < x.length; i += stop - start) { 29 | acc.push(x.slice(i, i + stop - start)); 30 | } 31 | } 32 | else acc.push(x) 33 | return acc; 34 | }, []) 35 | ; 36 | 37 | return chunks.reduce(function (lines, rawChunk) { 38 | if (rawChunk === '') return lines; 39 | 40 | var chunk = rawChunk.replace(/\t/g, ' '); 41 | 42 | var i = lines.length - 1; 43 | if (lines[i].length + chunk.length > stop) { 44 | lines[i] = lines[i].replace(/\s+$/, ''); 45 | 46 | chunk.split(/\n/).forEach(function (c) { 47 | lines.push( 48 | new Array(start + 1).join(' ') 49 | + c.replace(/^\s+/, '') 50 | ); 51 | }); 52 | } 53 | else if (chunk.match(/\n/)) { 54 | var xs = chunk.split(/\n/); 55 | lines[i] += xs.shift(); 56 | xs.forEach(function (c) { 57 | lines.push( 58 | new Array(start + 1).join(' ') 59 | + c.replace(/^\s+/, '') 60 | ); 61 | }); 62 | } 63 | else { 64 | lines[i] += chunk; 65 | } 66 | 67 | return lines; 68 | }, [ new Array(start + 1).join(' ') ]).join('\n'); 69 | }; 70 | }; 71 | 72 | wordwrap.soft = wordwrap; 73 | 74 | wordwrap.hard = function (start, stop) { 75 | return wordwrap(start, stop, { mode : 'hard' }); 76 | }; 77 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wordwrap", 3 | "description": "Wrap those words. Show them at what columns to start and stop.", 4 | "version": "0.0.2", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/substack/node-wordwrap.git" 8 | }, 9 | "main": "./index.js", 10 | "keywords": [ 11 | "word", 12 | "wrap", 13 | "rule", 14 | "format", 15 | "column" 16 | ], 17 | "directories": { 18 | "lib": ".", 19 | "example": "example", 20 | "test": "test" 21 | }, 22 | "scripts": { 23 | "test": "expresso" 24 | }, 25 | "devDependencies": { 26 | "expresso": "=0.7.x" 27 | }, 28 | "engines": { 29 | "node": ">=0.4.0" 30 | }, 31 | "license": "MIT/X11", 32 | "author": { 33 | "name": "James Halliday", 34 | "email": "mail@substack.net", 35 | "url": "http://substack.net" 36 | }, 37 | "_npmUser": { 38 | "name": "maxogden", 39 | "email": "max@maxogden.com" 40 | }, 41 | "_id": "wordwrap@0.0.2", 42 | "dependencies": {}, 43 | "optionalDependencies": {}, 44 | "_engineSupported": true, 45 | "_npmVersion": "1.1.21", 46 | "_nodeVersion": "v0.6.18", 47 | "_defaultsLoaded": true, 48 | "_from": "wordwrap@>=0.0.1 <0.1.0" 49 | } 50 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/test/break.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var wordwrap = require('../'); 3 | 4 | exports.hard = function () { 5 | var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,' 6 | + '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",' 7 | + '"browser":"chrome/6.0"}' 8 | ; 9 | var s_ = wordwrap.hard(80)(s); 10 | 11 | var lines = s_.split('\n'); 12 | assert.equal(lines.length, 2); 13 | assert.ok(lines[0].length < 80); 14 | assert.ok(lines[1].length < 80); 15 | 16 | assert.equal(s, s_.replace(/\n/g, '')); 17 | }; 18 | 19 | exports.break = function () { 20 | var s = new Array(55+1).join('a'); 21 | var s_ = wordwrap.hard(20)(s); 22 | 23 | var lines = s_.split('\n'); 24 | assert.equal(lines.length, 3); 25 | assert.ok(lines[0].length === 20); 26 | assert.ok(lines[1].length === 20); 27 | assert.ok(lines[2].length === 15); 28 | 29 | assert.equal(s, s_.replace(/\n/g, '')); 30 | }; 31 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/node_modules/wordwrap/test/wrap.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var wordwrap = require('wordwrap'); 3 | 4 | var fs = require('fs'); 5 | var idleness = fs.readFileSync(__dirname + '/idleness.txt', 'utf8'); 6 | 7 | exports.stop80 = function () { 8 | var lines = wordwrap(80)(idleness).split(/\n/); 9 | var words = idleness.split(/\s+/); 10 | 11 | lines.forEach(function (line) { 12 | assert.ok(line.length <= 80, 'line > 80 columns'); 13 | var chunks = line.match(/\S/) ? line.split(/\s+/) : []; 14 | assert.deepEqual(chunks, words.splice(0, chunks.length)); 15 | }); 16 | }; 17 | 18 | exports.start20stop60 = function () { 19 | var lines = wordwrap(20, 100)(idleness).split(/\n/); 20 | var words = idleness.split(/\s+/); 21 | 22 | lines.forEach(function (line) { 23 | assert.ok(line.length <= 100, 'line > 100 columns'); 24 | var chunks = line 25 | .split(/\s+/) 26 | .filter(function (x) { return x.match(/\S/) }) 27 | ; 28 | assert.deepEqual(chunks, words.splice(0, chunks.length)); 29 | assert.deepEqual(line.slice(0, 20), new Array(20 + 1).join(' ')); 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "optimist", 3 | "version": "0.2.8", 4 | "description": "Light-weight option parsing with an argv hash. No optstrings attached.", 5 | "main": "./index.js", 6 | "directories": { 7 | "lib": ".", 8 | "test": "test", 9 | "example": "examples" 10 | }, 11 | "dependencies": { 12 | "wordwrap": ">=0.0.1 <0.1.0" 13 | }, 14 | "devDependencies": { 15 | "hashish": "0.0.x", 16 | "expresso": "0.7.x" 17 | }, 18 | "scripts": { 19 | "test": "expresso" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git://github.com/substack/node-optimist.git" 24 | }, 25 | "keywords": [ 26 | "argument", 27 | "args", 28 | "option", 29 | "parser", 30 | "parsing", 31 | "cli", 32 | "command" 33 | ], 34 | "author": { 35 | "name": "James Halliday", 36 | "email": "mail@substack.net", 37 | "url": "http://substack.net" 38 | }, 39 | "license": "MIT/X11", 40 | "engine": { 41 | "node": ">=0.4" 42 | }, 43 | "_npmUser": { 44 | "name": "maxogden", 45 | "email": "max@maxogden.com" 46 | }, 47 | "_id": "optimist@0.2.8", 48 | "optionalDependencies": {}, 49 | "engines": { 50 | "node": "*" 51 | }, 52 | "_engineSupported": true, 53 | "_npmVersion": "1.1.21", 54 | "_nodeVersion": "v0.6.18", 55 | "_defaultsLoaded": true, 56 | "_from": "optimist@0.2" 57 | } 58 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/test/_.js: -------------------------------------------------------------------------------- 1 | var spawn = require('child_process').spawn; 2 | var assert = require('assert'); 3 | 4 | exports.dotSlashEmpty = function () { 5 | testCmd('./bin.js', []); 6 | }; 7 | 8 | exports.dotSlashArgs = function () { 9 | testCmd('./bin.js', [ 'a', 'b', 'c' ]); 10 | }; 11 | 12 | exports.nodeEmpty = function () { 13 | testCmd('node bin.js', []); 14 | }; 15 | 16 | exports.nodeArgs = function () { 17 | testCmd('node bin.js', [ 'x', 'y', 'z' ]); 18 | }; 19 | 20 | exports.whichNodeEmpty = function () { 21 | var which = spawn('which', ['node']); 22 | 23 | which.stdout.on('data', function (buf) { 24 | testCmd(buf.toString().trim() + ' bin.js', []); 25 | }); 26 | 27 | which.stderr.on('data', function (err) { 28 | assert.fail(err.toString()); 29 | }); 30 | }; 31 | 32 | exports.whichNodeArgs = function () { 33 | var which = spawn('which', ['node']); 34 | 35 | which.stdout.on('data', function (buf) { 36 | testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ]); 37 | }); 38 | 39 | which.stderr.on('data', function (err) { 40 | assert.fail(err.toString()); 41 | }); 42 | }; 43 | 44 | function testCmd (cmd, args) { 45 | var to = setTimeout(function () { 46 | assert.fail('Never got stdout data.') 47 | }, 5000); 48 | 49 | var oldDir = process.cwd(); 50 | process.chdir(__dirname + '/_'); 51 | 52 | var cmds = cmd.split(' '); 53 | 54 | var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String))); 55 | process.chdir(oldDir); 56 | 57 | bin.stderr.on('data', function (err) { 58 | assert.fail(err.toString()); 59 | }); 60 | 61 | bin.stdout.on('data', function (buf) { 62 | clearTimeout(to); 63 | var _ = JSON.parse(buf.toString()); 64 | assert.eql(_.map(String), args.map(String)); 65 | }); 66 | } 67 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/test/_/argv.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.log(JSON.stringify(process.argv)); 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/node_modules/optimist/test/_/bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var argv = require('../../index').argv 3 | console.log(JSON.stringify(argv._)); 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "event-stream", 3 | "version": "2.0.4", 4 | "description": "construct pipes of streams of events", 5 | "homepage": "http://github.com/dominictarr/event-stream", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/dominictarr/event-stream.git" 9 | }, 10 | "dependencies": { 11 | "optimist": "0.2" 12 | }, 13 | "devDependencies": { 14 | "asynct": "*", 15 | "it-is": "1", 16 | "ubelt": "~2.9" 17 | }, 18 | "scripts": { 19 | "test": "asynct test/" 20 | }, 21 | "author": { 22 | "name": "Dominic Tarr", 23 | "email": "dominic.tarr@gmail.com", 24 | "url": "http://bit.ly/dominictarr" 25 | }, 26 | "optionalDependencies": {}, 27 | "engines": { 28 | "node": "*" 29 | }, 30 | "_npmUser": { 31 | "name": "maxogden", 32 | "email": "max@maxogden.com" 33 | }, 34 | "_id": "event-stream@2.0.4", 35 | "_engineSupported": true, 36 | "_npmVersion": "1.1.21", 37 | "_nodeVersion": "v0.6.18", 38 | "_defaultsLoaded": true, 39 | "_from": "event-stream" 40 | } 41 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/connect.asynct.js: -------------------------------------------------------------------------------- 1 | var es = require('../') 2 | , it = require('it-is').style('colour') 3 | , d = require('ubelt') 4 | 5 | function makeExamplePipe() { 6 | 7 | return es.connect( 8 | es.map(function (data, callback) { 9 | callback(null, data * 2) 10 | }), 11 | es.map(function (data, callback) { 12 | d.delay(callback)(null, data) 13 | }), 14 | es.map(function (data, callback) { 15 | callback(null, data + 2) 16 | })) 17 | } 18 | 19 | exports['simple pipe'] = function (test) { 20 | 21 | var pipe = makeExamplePipe() 22 | 23 | pipe.on('data', function (data) { 24 | it(data).equal(18) 25 | test.done() 26 | }) 27 | 28 | pipe.write(8) 29 | 30 | } 31 | 32 | exports['read array then map'] = function (test) { 33 | 34 | var readThis = d.map(3, 6, 100, d.id) //array of multiples of 3 < 100 35 | , first = es.readArray(readThis) 36 | , read = [] 37 | , pipe = 38 | es.connect( 39 | first, 40 | es.map(function (data, callback) { 41 | callback(null, {data: data}) 42 | }), 43 | es.map(function (data, callback) { 44 | callback(null, {data: data}) 45 | }), 46 | es.writeArray(function (err, array) { 47 | it(array).deepEqual(d.map(readThis, function (data) { 48 | return {data: {data: data}} 49 | })) 50 | test.done() 51 | }) 52 | ) 53 | } 54 | 55 | exports ['connect returns a stream'] = function (test) { 56 | 57 | var rw = 58 | es.connect( 59 | es.map(function (data, callback) { 60 | callback(null, data * 2) 61 | }), 62 | es.map(function (data, callback) { 63 | callback(null, data * 5) 64 | }) 65 | ) 66 | 67 | it(rw).has({readable: true, writable: true}) 68 | 69 | var array = [190, 24, 6, 7, 40, 57, 4, 6] 70 | , _array = [] 71 | , c = 72 | es.connect( 73 | es.readArray(array), 74 | rw, 75 | es.log('after rw:'), 76 | es.writeArray(function (err, _array) { 77 | it(_array).deepEqual(array.map(function (e) { return e * 10 })) 78 | test.done() 79 | }) 80 | ) 81 | 82 | } 83 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/gate.asynct.js: -------------------------------------------------------------------------------- 1 | 2 | var es = require('../') 3 | , it = require('it-is') 4 | , d = require('ubelt') 5 | 6 | exports ['gate buffers when shut'] = function (test) { 7 | 8 | var hundy = d.map(1,100, d.id) 9 | , gate = es.gate() 10 | , ten = 10 11 | es.connect( 12 | es.readArray(hundy), 13 | //es.log('after readArray'), 14 | gate, 15 | //es.log('after gate'), 16 | es.map(function (num, next) { 17 | //stick a map in here to check that gate never emits when open 18 | it(gate.isShut()).equal(false) 19 | 20 | if(!--ten) { 21 | gate.shut() 22 | d.delay(gate.open,10)() 23 | ten = 10 24 | } 25 | 26 | next(null, num) 27 | }), 28 | es.writeArray(function (err, array) { //just realized that I should remove the error param. errors will be emitted 29 | console.log('eonuhoenuoecbulc') 30 | it(array).deepEqual(hundy) 31 | test.done() 32 | }) 33 | ) 34 | 35 | gate.open() 36 | 37 | } 38 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/merge.asynct.js: -------------------------------------------------------------------------------- 1 | var es = require('../') 2 | , it = require('it-is').style('colour') 3 | , d = require('ubelt') 4 | 5 | exports.merge = function (t) { 6 | var odd = d.map(1, 3, 100, d.id) //array of multiples of 3 < 100 7 | var even = d.map(2, 4, 100, d.id) //array of multiples of 3 < 100 8 | 9 | var r1 = es.readArray(even) 10 | var r2 = es.readArray(odd) 11 | 12 | var writer = es.writeArray(function (err, array){ 13 | if(err) throw err //unpossible 14 | it(array.sort()).deepEqual(even.concat(odd).sort()) 15 | t.done() 16 | }) 17 | 18 | es.merge(r1, r2).pipe(writer) 19 | 20 | } 21 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/readArray.asynct.js: -------------------------------------------------------------------------------- 1 | 2 | var es = require('../') 3 | , it = require('it-is').style('colour') 4 | , d = require('ubelt') 5 | 6 | function readStream(stream, pauseAt, done) { 7 | if(!done) done = pauseAt, pauseAt = -1 8 | var array = [] 9 | stream.on('data', function (data) { 10 | array.push(data) 11 | if(!--pauseAt ) 12 | stream.pause(), done(null, array) 13 | }) 14 | stream.on('error', done) 15 | stream.on('end', function (data) { 16 | done(null, array) 17 | }) 18 | 19 | } 20 | 21 | exports ['read an array'] = function (test) { 22 | 23 | var readThis = d.map(3, 6, 100, d.id) //array of multiples of 3 < 100 24 | 25 | var reader = es.readArray(readThis) 26 | 27 | var writer = es.writeArray(function (err, array){ 28 | if(err) throw err //unpossible 29 | it(array).deepEqual(readThis) 30 | test.done() 31 | }) 32 | 33 | reader.pipe(writer) 34 | } 35 | 36 | exports ['read an array and pause it.'] = function (test) { 37 | 38 | var readThis = d.map(3, 6, 100, d.id) //array of multiples of 3 < 100 39 | 40 | var reader = es.readArray(readThis) 41 | 42 | readStream(reader, 10, function (err, data) { 43 | if(err) throw err 44 | it(data).deepEqual([3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) 45 | readStream(reader, 10, function (err, data) { 46 | it(data).deepEqual([33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) 47 | test.done() 48 | }) 49 | reader.resume() 50 | }) 51 | 52 | } 53 | 54 | exports ['reader is readable, but not writeable'] = function (test) { 55 | var reader = es.readArray([1]) 56 | it(reader).has({ 57 | readable: true, 58 | writable: false 59 | }) 60 | 61 | test.done() 62 | } 63 | 64 | 65 | exports ['read one item per tick'] = function (test) { 66 | var readThis = d.map(3, 6, 100, d.id) //array of multiples of 3 < 100 67 | var drains = 0 68 | var reader = es.readArray(readThis) 69 | var tickMapper = es.map(function (data,callback) { 70 | process.nextTick(function () { 71 | callback(null, data) 72 | }) 73 | //since tickMapper is returning false 74 | //pipe should pause the writer until a drain occurs 75 | return false 76 | }) 77 | reader.pipe(tickMapper) 78 | readStream(tickMapper, function (err, array) { 79 | it(array).deepEqual(readThis) 80 | it(array.length).deepEqual(readThis.length) 81 | it(drains).equal(readThis.length) 82 | test.done() 83 | }) 84 | tickMapper.on('drain', function () { 85 | drains ++ 86 | }) 87 | 88 | } 89 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/replace.asynct.js: -------------------------------------------------------------------------------- 1 | var es = require('../') 2 | , it = require('it-is').style('colour') 3 | , d = require('ubelt') 4 | 5 | var fizzbuzz = '12F4BF78FB11F1314FB1617F19BF2223FB26F2829FB3132F34BF3738FB41F4344FB4647F49BF5253FB56F5859FB6162F64BF6768FB71F7374FB7677F79BF8283FB86F8889FB9192F94BF9798FB' 6 | , fizz7buzz = '12F4BFseven8FB11F1314FB161sevenF19BF2223FB26F2829FB3132F34BF3seven38FB41F4344FB464sevenF49BF5253FB56F5859FB6162F64BF6seven68FBseven1Fseven3seven4FBseven6sevensevenFseven9BF8283FB86F8889FB9192F94BF9seven98FB' 7 | 8 | exports ['fizz buzz'] = function (test) { 9 | 10 | var readThis = d.map(1, 100, function (i) { 11 | return ( 12 | ! (i % 3 || i % 5) ? "FB" : 13 | !(i % 3) ? "F" : 14 | !(i % 5) ? "B" : 15 | ''+i 16 | ) 17 | }) //array of multiples of 3 < 100 18 | 19 | var reader = es.readArray(readThis) 20 | 21 | var join = es.join(function (err, string){ 22 | it(string).equal(fizzbuzz) 23 | test.done() 24 | }) 25 | reader.pipe(join) 26 | 27 | } 28 | 29 | 30 | exports ['fizz buzz replace'] = function (test) { 31 | var split = es.split(/(1)/) 32 | 33 | var replace = es.replace('7', 'seven') 34 | 35 | es.connect(split, 36 | replace, 37 | // es.log('aeounh'), 38 | es.join(function (err, string) { 39 | it(string).equal(fizz7buzz) 40 | test.done() 41 | }) 42 | ) 43 | 44 | split.write(fizzbuzz) 45 | split.end() 46 | 47 | } 48 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/split.asynct.js: -------------------------------------------------------------------------------- 1 | var es = require('../') 2 | , it = require('it-is').style('colour') 3 | , d = require('ubelt') 4 | , join = require('path').join 5 | , fs = require('fs') 6 | , Stream = require('stream').Stream 7 | 8 | exports ['pipeable'] = function (test) { 9 | var readme = join(__filename) 10 | , expected = fs.readFileSync(readme, 'utf-8').split('\n') 11 | , cs = es.split() 12 | , actual = [] 13 | , ended = false 14 | 15 | var a = new Stream () 16 | 17 | a.write = function (l) { 18 | actual.push(l.trim()) 19 | } 20 | a.end = function () { 21 | 22 | ended = true 23 | expected.forEach(function (v,k) { 24 | //String.split will append an empty string '' 25 | //if the string ends in a split pattern. 26 | //es.split doesn't which was breaking this test. 27 | //clearly, appending the empty string is correct. 28 | //tests are passing though. which is the current job. 29 | if(v) 30 | it(actual[k]).like(v) 31 | }) 32 | console.log('88888888888888888888888!!!') 33 | test.done() 34 | } 35 | a.writable = true 36 | 37 | fs.createReadStream(readme, {flags: 'r'}).pipe(cs) 38 | cs.pipe(a) 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/event-stream/test/writeArray.asynct.js: -------------------------------------------------------------------------------- 1 | 2 | var es = require('../') 3 | , it = require('it-is').style('colour') 4 | , d = require('ubelt') 5 | 6 | exports ['write an array'] = function (test) { 7 | 8 | var readThis = d.map(3, 6, 100, d.id) //array of multiples of 3 < 100 9 | 10 | var writer = es.writeArray(function (err, array){ 11 | if(err) throw err //unpossible 12 | it(array).deepEqual(readThis) 13 | test.done() 14 | }) 15 | 16 | d.each(readThis, writer.write.bind(writer)) 17 | writer.end() 18 | 19 | } 20 | 21 | 22 | exports ['writer is writable, but not readable'] = function (test) { 23 | var reader = es.writeArray(function () {}) 24 | it(reader).has({ 25 | readable: false, 26 | writable: true 27 | }) 28 | 29 | test.done() 30 | } 31 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/mediastream/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DOMNode getUserMedia 7 | 8 | 9 | 10 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/mediastream/index.js: -------------------------------------------------------------------------------- 1 | var stream = require('stream') 2 | var util = require('util') 3 | 4 | function MediaStream(options) { 5 | var me = this 6 | stream.Stream.call(me) 7 | this.readable = true 8 | var getUserMedia = me.getGetUserMedia() 9 | if (!getUserMedia) return console.log({"error": "getUserMedia not supported in this browser"}) 10 | navigator.webkitGetUserMedia(options, 11 | function(stream) { 12 | var video = me.video = me.createHiddenVideo() 13 | video.src = window.webkitURL.createObjectURL(stream) 14 | video.play() 15 | }, 16 | function(err) { 17 | console.log('error', err) 18 | } 19 | ) 20 | } 21 | 22 | util.inherits(MediaStream, stream.Stream) 23 | 24 | module.exports = function(options) { 25 | return new MediaStream(options) 26 | } 27 | 28 | module.exports.MediaStream = MediaStream 29 | 30 | MediaStream.prototype.getGetUserMedia = function() { 31 | if (navigator.getUserMedia) return navigator.getUserMedia 32 | if (navigator.webkitGetUserMedia) return navigator.webkitGetUserMedia 33 | return false 34 | } 35 | 36 | MediaStream.prototype.onVideoPlay = function() { 37 | var video = this.video 38 | if (!isNaN(video.duration)) { 39 | this.canvas = this.createHiddenCanvas() 40 | setInterval(this.captureVideo.bind(this), 1) 41 | } else { 42 | setTimeout(this.onVideoPlay.bind(this), 100) 43 | } 44 | } 45 | 46 | MediaStream.prototype.captureVideo = function() { 47 | // var before = new Date() 48 | this.canvasContext.drawImage(this.video, 0, 0) 49 | var uri = this.canvas.toDataURL('image/webp') 50 | // console.log(new Date() - before) 51 | this.emit('data', uri) 52 | } 53 | 54 | MediaStream.prototype.createHiddenVideo = function() { 55 | var videoElement = document.createElement("video") 56 | videoElement.style.display = "none" 57 | document.querySelector('body').appendChild(videoElement) 58 | videoElement.addEventListener('play', this.onVideoPlay.bind(this)) 59 | return videoElement 60 | } 61 | 62 | MediaStream.prototype.createHiddenCanvas = function() { 63 | this.canvas = document.createElement("canvas") 64 | this.canvas.style.display = "none" 65 | document.querySelector('body').appendChild(this.canvas) 66 | this.canvas.width = this.video.videoWidth; 67 | this.canvas.height = this.video.videoHeight; 68 | this.canvasContext = this.canvas.getContext('2d') 69 | return this.canvas 70 | } -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/mediastream/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mediastream", 3 | "version": "0.0.4", 4 | "_npmUser": { 5 | "name": "maxogden", 6 | "email": "max@maxogden.com" 7 | }, 8 | "_id": "mediastream@0.0.4", 9 | "dependencies": {}, 10 | "devDependencies": {}, 11 | "optionalDependencies": {}, 12 | "engines": { 13 | "node": "*" 14 | }, 15 | "_engineSupported": true, 16 | "_npmVersion": "1.1.21", 17 | "_nodeVersion": "v0.6.18", 18 | "_defaultsLoaded": true, 19 | "_from": "mediastream" 20 | } 21 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/mediastream/readme.md: -------------------------------------------------------------------------------- 1 | # domnode-usermedia 2 | 3 | use HTML5 [WebRTC](http://www.html5rocks.com/en/tutorials/getusermedia/intro/) the node way -- with streams 4 | 5 | var media = new MediaStream({video: true}) 6 | 7 | `media` is a readable stream and speaks stream events: `data`, `error` and `end`. that means you can pipe media output to anything that accepts streams, such as an XHR. in this case the `data` events will be DataURI representations of the user's webcam frame captures 8 | 9 | ## limitations 10 | 11 | browsers only let you get webcam video right now (even though you can include `audio: true` in the options there is no way to capture the audio) 12 | 13 | MIT LICENSE -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/.npmignore: -------------------------------------------------------------------------------- 1 | example/*/node_modules 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/browser.js: -------------------------------------------------------------------------------- 1 | var Stream = require('stream'); 2 | var sockjs = require('sockjs-client'); 3 | 4 | module.exports = function (uri, cb) { 5 | if (/^\/\/[^\/]+\//.test(uri)) { 6 | uri = window.location.protocol + uri; 7 | } 8 | else if (!/^https?:\/\//.test(uri)) { 9 | uri = window.location.protocol + '//' 10 | + window.location.host 11 | + (/^\//.test(uri) ? uri : '/' + uri) 12 | ; 13 | } 14 | 15 | var stream = new Stream; 16 | stream.readable = true; 17 | stream.writable = true; 18 | 19 | var ready = false; 20 | var buffer = []; 21 | 22 | var sock = sockjs(uri); 23 | stream.sock = sock; 24 | 25 | stream.write = function (msg) { 26 | if (!ready) buffer.push(msg) 27 | else sock.send(msg) 28 | }; 29 | 30 | sock.onopen = function () { 31 | if (typeof cb === 'function') cb(); 32 | ready = true; 33 | buffer.forEach(function (msg) { 34 | sock.send(msg); 35 | }); 36 | buffer = []; 37 | }; 38 | sock.onmessage = function (e) { 39 | stream.emit('data', e.data); 40 | }; 41 | sock.onclose = function () { 42 | stream.emit('end'); 43 | stream.writable = false; 44 | stream.readable = false; 45 | }; 46 | 47 | return stream; 48 | }; 49 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/dnode/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | node_modules/.bin/browserify client.js -o static/bundle.js 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/dnode/client.js: -------------------------------------------------------------------------------- 1 | var domready = require('domready'); 2 | var shoe = require('../../'); 3 | var dnode = require('dnode'); 4 | 5 | domready(function () { 6 | var result = document.getElementById('result'); 7 | var stream = shoe('/dnode'); 8 | 9 | var d = dnode(); 10 | d.on('remote', function (remote) { 11 | remote.transform('beep', function (s) { 12 | result.textContent = 'beep => ' + s; 13 | }); 14 | }); 15 | d.pipe(stream).pipe(d); 16 | }); 17 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/dnode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "shoe-dnode-example", 3 | "version" : "0.0.0", 4 | "dependencies" : { 5 | "browserify" : "~1.13.0", 6 | "ecstatic" : "~0.1.6", 7 | "domready" : "~0.2.11", 8 | "dnode" : "~1.0.0" 9 | }, 10 | "private" : true 11 | } 12 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/dnode/server.js: -------------------------------------------------------------------------------- 1 | var shoe = require('../../'); 2 | var dnode = require('dnode'); 3 | 4 | var http = require('http'); 5 | var ecstatic = require('ecstatic')(__dirname + '/static'); 6 | 7 | var server = http.createServer(ecstatic); 8 | server.listen(9999); 9 | 10 | var sock = shoe(function (stream) { 11 | var d = dnode({ 12 | transform : function (s, cb) { 13 | var res = s.replace(/[aeiou]{2,}/, 'oo').toUpperCase(); 14 | cb(res); 15 | } 16 | }); 17 | d.pipe(stream).pipe(d); 18 | }); 19 | sock.install(server, '/dnode'); 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/dnode/static/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/invert/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | node_modules/.bin/browserify client.js -o static/bundle.js 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/invert/client.js: -------------------------------------------------------------------------------- 1 | var shoe = require('../../'); 2 | var domready = require('domready'); 3 | var es = require('event-stream'); 4 | 5 | domready(function () { 6 | var result = document.getElementById('result'); 7 | 8 | var stream = shoe('/invert'); 9 | var s = es.mapSync(function (msg) { 10 | result.appendChild(document.createTextNode(msg)); 11 | return String(Number(msg)^1); 12 | }); 13 | s.pipe(stream).pipe(s); 14 | }); 15 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/invert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "shoe-invert-example", 3 | "version" : "0.0.0", 4 | "dependencies" : { 5 | "browserify" : "~1.13.0", 6 | "ecstatic" : "~0.1.6", 7 | "domready" : "~0.2.11", 8 | "event-stream" : "~2.0.4" 9 | }, 10 | "private" : true 11 | } 12 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/invert/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var ecstatic = require('ecstatic')(__dirname + '/static'); 3 | var shoe = require('../../'); 4 | 5 | var server = http.createServer(ecstatic); 6 | server.listen(9999); 7 | 8 | var sock = shoe(function (stream) { 9 | var iv = setInterval(function () { 10 | stream.write(Math.floor(Math.random() * 2)); 11 | }, 250); 12 | 13 | stream.on('end', function () { 14 | clearInterval(iv); 15 | }); 16 | 17 | stream.pipe(process.stdout, { end : false }); 18 | }); 19 | sock.install(server, '/invert'); 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/example/invert/static/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/index.js: -------------------------------------------------------------------------------- 1 | var sockjs = require('sockjs'); 2 | 3 | exports = module.exports = function (opts, cb) { 4 | if (typeof opts === 'function') { 5 | cb = opts; 6 | opts = {}; 7 | } 8 | var server = sockjs.createServer(); 9 | if (typeof cb === 'function') { 10 | server.on('connection', cb); 11 | } 12 | server.install = function (httpServer, hopts) { 13 | if (hopts && hopts.listen && !httpServer.listen) { 14 | httpServer = arguments[1]; 15 | hopts = arguments[0]; 16 | } 17 | if (typeof hopts === 'string') { 18 | hopts = { prefix : hopts }; 19 | } 20 | if (!hopts) hopts = {}; 21 | if (hopts.log === undefined) { 22 | // spamming stdout by default is VERY infuriating, 23 | // emit an event instead 24 | hopts.log = function (severity, line) { 25 | server.emit('log', severity, line); 26 | }; 27 | } 28 | server.installHandlers(httpServer, hopts); 29 | }; 30 | 31 | return server; 32 | }; 33 | 34 | Object.keys(sockjs).forEach(function (key) { 35 | exports[key] = sockjs[key]; 36 | }); 37 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/.npmignore: -------------------------------------------------------------------------------- 1 | .testling_env.sh 2 | bin/.testling_env.sh 3 | tests 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/COPYING: -------------------------------------------------------------------------------- 1 | Parts of the code are derived from various open source projects. 2 | 3 | For code derived from Socket.IO by Guillermo Rauch see 4 | https://github.com/LearnBoost/socket.io/tree/0.6.17#readme. 5 | 6 | Snippets derived from JSON-js by Douglas Crockford are public domain. 7 | 8 | Snippets derived from jQuery-JSONP by Julian Aubourg, generic MIT 9 | license. 10 | 11 | All other code is released on MIT license, see LICENSE-MIT-SockJS. 12 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/LICENSE-MIT-SockJS: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 VMware, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/VERSION-GEN: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LF=' 4 | ' 5 | 6 | VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) 7 | case "$VN" in 8 | *$LF*) (exit 1) ;; 9 | v[0-9]*) 10 | git update-index -q --refresh 11 | test -z "$(git diff-index --name-only HEAD --)" || 12 | VN="$VN-dirty" ;; 13 | esac 14 | VN=$(echo "$VN" | sed -e 's/-/./g'); 15 | VN=$(expr "$VN" : v*'\(.*\)') 16 | 17 | echo "$VN" 18 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/all.js: -------------------------------------------------------------------------------- 1 | /* SockJS client, version , http://sockjs.org, MIT License 2 | 3 | 4 | */ 5 | 6 | // JSON2 by Douglas Crockford (minified). 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/eventemitter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var EventEmitter = function(events) { 10 | this.events = events || []; 11 | }; 12 | EventEmitter.prototype.emit = function(type) { 13 | var that = this; 14 | var args = Array.prototype.slice.call(arguments, 1); 15 | if (!that.nuked && that['on'+type]) { 16 | that['on'+type].apply(that, args); 17 | } 18 | if (utils.arrIndexOf(that.events, type) === -1) { 19 | utils.log('Event ' + JSON.stringify(type) + 20 | ' not listed ' + JSON.stringify(that.events) + 21 | ' in ' + that); 22 | } 23 | }; 24 | 25 | EventEmitter.prototype.nuke = function(type) { 26 | var that = this; 27 | that.nuked = true; 28 | for(var i=0; i 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | return SockJS; 31 | })(); 32 | if ('_sockjs_onload' in window) setTimeout(_sockjs_onload, 1); 33 | 34 | // AMD compliance 35 | if (typeof define === 'function' && define.amd) { 36 | define('sockjs', [], function(){return SockJS;}); 37 | } 38 | 39 | if (typeof module === 'object' && module && module.exports) { 40 | module.exports = SockJS; 41 | } 42 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/json2.min.js: -------------------------------------------------------------------------------- 1 | var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c 1) { 35 | this._listeners[eventType] = arr.slice(0, idx).concat( arr.slice(idx+1) ); 36 | } else { 37 | delete this._listeners[eventType]; 38 | } 39 | return; 40 | } 41 | return; 42 | }; 43 | 44 | REventTarget.prototype.dispatchEvent = function (event) { 45 | var t = event.type; 46 | var args = Array.prototype.slice.call(arguments, 0); 47 | if (this['on'+t]) { 48 | this['on'+t].apply(this, args); 49 | } 50 | if (this._listeners && t in this._listeners) { 51 | for(var i=0; i < this._listeners[t].length; i++) { 52 | this._listeners[t][i].apply(this, args); 53 | } 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/simpleevent.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var SimpleEvent = function(type, obj) { 10 | this.type = type; 11 | if (typeof obj !== 'undefined') { 12 | for(var k in obj) { 13 | if (!obj.hasOwnProperty(k)) continue; 14 | this[k] = obj[k]; 15 | } 16 | } 17 | }; 18 | 19 | SimpleEvent.prototype.toString = function() { 20 | var r = []; 21 | for(var k in this) { 22 | if (!this.hasOwnProperty(k)) continue; 23 | var v = this[k]; 24 | if (typeof v === 'function') v = '[function]'; 25 | r.push(k + '=' + v); 26 | } 27 | return 'SimpleEvent(' + r.join(', ') + ')'; 28 | }; 29 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/test-hooks.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | // For testing 10 | SockJS.getUtils = function(){ 11 | return utils; 12 | }; 13 | 14 | SockJS.getIframeTransport = function(){ 15 | return IframeTransport; 16 | }; 17 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-eventsource.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var EventSourceIframeTransport = SockJS['iframe-eventsource'] = function () { 10 | var that = this; 11 | that.protocol = 'w-iframe-eventsource'; 12 | that.i_constructor.apply(that, arguments); 13 | }; 14 | 15 | EventSourceIframeTransport.prototype = new IframeTransport(); 16 | 17 | EventSourceIframeTransport.enabled = function () { 18 | return ('EventSource' in _window) && IframeTransport.enabled(); 19 | }; 20 | 21 | EventSourceIframeTransport.need_body = true; 22 | EventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource 23 | 24 | 25 | // w-iframe-eventsource 26 | var EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function(ri, trans_url) { 27 | this.run(ri, trans_url, '/eventsource', EventSourceReceiver, utils.XHRLocalObject); 28 | } 29 | EventSourceTransport.prototype = new AjaxBasedTransport(); 30 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-htmlfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | // This transport generally works in any browser, but will cause a 10 | // spinning cursor to appear in any browser other than IE. 11 | // We may test this transport in all browsers - why not, but in 12 | // production it should be only run in IE. 13 | 14 | var HtmlFileIframeTransport = SockJS['iframe-htmlfile'] = function () { 15 | var that = this; 16 | that.protocol = 'w-iframe-htmlfile'; 17 | that.i_constructor.apply(that, arguments); 18 | }; 19 | 20 | // Inheritance. 21 | HtmlFileIframeTransport.prototype = new IframeTransport(); 22 | 23 | HtmlFileIframeTransport.enabled = function() { 24 | return IframeTransport.enabled(); 25 | }; 26 | 27 | HtmlFileIframeTransport.need_body = true; 28 | HtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile 29 | 30 | 31 | // w-iframe-htmlfile 32 | var HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function(ri, trans_url) { 33 | this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, utils.XHRLocalObject); 34 | }; 35 | HtmlFileTransport.prototype = new AjaxBasedTransport(); 36 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-within.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var curr_window_id; 10 | 11 | var postMessage = function (type, data) { 12 | if(parent !== _window) { 13 | parent.postMessage(curr_window_id + type + (data || ''), '*'); 14 | } else { 15 | utils.log("Can't postMessage, no parent window.", type, data); 16 | } 17 | }; 18 | 19 | var FacadeJS = function() {}; 20 | FacadeJS.prototype._didClose = function (code, reason) { 21 | postMessage('t', utils.closeFrame(code, reason)); 22 | }; 23 | FacadeJS.prototype._didMessage = function (frame) { 24 | postMessage('t', frame); 25 | }; 26 | FacadeJS.prototype._doSend = function (data) { 27 | this._transport.doSend(data); 28 | }; 29 | FacadeJS.prototype._doCleanup = function () { 30 | this._transport.doCleanup(); 31 | }; 32 | 33 | utils.parent_origin = undefined; 34 | 35 | SockJS.bootstrap_iframe = function() { 36 | var facade; 37 | curr_window_id = _document.location.hash.slice(1); 38 | var onMessage = function(e) { 39 | if(e.source !== parent) return; 40 | if(typeof utils.parent_origin === 'undefined') 41 | utils.parent_origin = e.origin; 42 | if (e.origin !== utils.parent_origin) return; 43 | 44 | var window_id = e.data.slice(0, 8); 45 | var type = e.data.slice(8, 9); 46 | var data = e.data.slice(9); 47 | if (window_id !== curr_window_id) return; 48 | switch(type) { 49 | case 's': 50 | var p = JSON.parse(data); 51 | var version = p[0]; 52 | var protocol = p[1]; 53 | var trans_url = p[2]; 54 | var base_url = p[3]; 55 | if (version !== SockJS.version) { 56 | utils.log("Incompatibile SockJS! Main site uses:" + 57 | " \"" + version + "\", the iframe:" + 58 | " \"" + SockJS.version + "\"."); 59 | } 60 | if (!utils.flatUrl(trans_url) || !utils.flatUrl(base_url)) { 61 | utils.log("Only basic urls are supported in SockJS"); 62 | return; 63 | } 64 | 65 | if (!utils.isSameOriginUrl(trans_url) || 66 | !utils.isSameOriginUrl(base_url)) { 67 | utils.log("Can't connect to different domain from within an " + 68 | "iframe. (" + JSON.stringify([_window.location.href, trans_url, base_url]) + 69 | ")"); 70 | return; 71 | } 72 | facade = new FacadeJS(); 73 | facade._transport = new FacadeJS[protocol](facade, trans_url, base_url); 74 | break; 75 | case 'm': 76 | facade._doSend(data); 77 | break; 78 | case 'c': 79 | if (facade) 80 | facade._doCleanup(); 81 | facade = null; 82 | break; 83 | } 84 | }; 85 | 86 | // alert('test ticker'); 87 | // facade = new FacadeJS(); 88 | // facade._transport = new FacadeJS['w-iframe-xhr-polling'](facade, 'http://host.com:9999/ticker/12/basd'); 89 | 90 | utils.attachMessage(onMessage); 91 | 92 | // Start 93 | postMessage('s'); 94 | }; 95 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-iframe-xhr-polling.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var XhrPollingIframeTransport = SockJS['iframe-xhr-polling'] = function () { 10 | var that = this; 11 | that.protocol = 'w-iframe-xhr-polling'; 12 | that.i_constructor.apply(that, arguments); 13 | }; 14 | 15 | XhrPollingIframeTransport.prototype = new IframeTransport(); 16 | 17 | XhrPollingIframeTransport.enabled = function () { 18 | return _window.XMLHttpRequest && IframeTransport.enabled(); 19 | }; 20 | 21 | XhrPollingIframeTransport.need_body = true; 22 | XhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr 23 | 24 | 25 | // w-iframe-xhr-polling 26 | var XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function(ri, trans_url) { 27 | this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRLocalObject); 28 | }; 29 | 30 | XhrPollingITransport.prototype = new AjaxBasedTransport(); 31 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-jsonp-polling.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | // The simplest and most robust transport, using the well-know cross 10 | // domain hack - JSONP. This transport is quite inefficient - one 11 | // mssage could use up to one http request. But at least it works almost 12 | // everywhere. 13 | // Known limitations: 14 | // o you will get a spinning cursor 15 | // o for Konqueror a dumb timer is needed to detect errors 16 | 17 | 18 | var JsonPTransport = SockJS['jsonp-polling'] = function(ri, trans_url) { 19 | utils.polluteGlobalNamespace(); 20 | var that = this; 21 | that.ri = ri; 22 | that.trans_url = trans_url; 23 | that.send_constructor(jsonPGenericSender); 24 | that._schedule_recv(); 25 | }; 26 | 27 | // Inheritnace 28 | JsonPTransport.prototype = new BufferedSender(); 29 | 30 | JsonPTransport.prototype._schedule_recv = function() { 31 | var that = this; 32 | var callback = function(data) { 33 | that._recv_stop = null; 34 | if (data) { 35 | // no data - heartbeat; 36 | if (!that._is_closing) { 37 | that.ri._didMessage(data); 38 | } 39 | } 40 | // The message can be a close message, and change is_closing state. 41 | if (!that._is_closing) { 42 | that._schedule_recv(); 43 | } 44 | }; 45 | that._recv_stop = jsonPReceiverWrapper(that.trans_url + '/jsonp', 46 | jsonPGenericReceiver, callback); 47 | }; 48 | 49 | JsonPTransport.enabled = function() { 50 | return true; 51 | }; 52 | 53 | JsonPTransport.need_body = true; 54 | 55 | 56 | JsonPTransport.prototype.doCleanup = function() { 57 | var that = this; 58 | that._is_closing = true; 59 | if (that._recv_stop) { 60 | that._recv_stop(); 61 | } 62 | that.ri = that._recv_stop = null; 63 | that.send_destructor(); 64 | }; 65 | 66 | 67 | // Abstract away code that handles global namespace pollution. 68 | var jsonPReceiverWrapper = function(url, constructReceiver, user_callback) { 69 | var id = 'a' + utils.random_string(6); 70 | var url_id = url + '?c=' + escape(WPrefix + '.' + id); 71 | // Callback will be called exactly once. 72 | var callback = function(frame) { 73 | delete _window[WPrefix][id]; 74 | user_callback(frame); 75 | }; 76 | 77 | var close_script = constructReceiver(url_id, callback); 78 | _window[WPrefix][id] = close_script; 79 | var stop = function() { 80 | if (_window[WPrefix][id]) { 81 | _window[WPrefix][id](utils.closeFrame(1000, "JSONP user aborted read")); 82 | } 83 | }; 84 | return stop; 85 | }; 86 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-polling.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var Polling = function(ri, Receiver, recv_url, AjaxObject) { 10 | var that = this; 11 | that.ri = ri; 12 | that.Receiver = Receiver; 13 | that.recv_url = recv_url; 14 | that.AjaxObject = AjaxObject; 15 | that._scheduleRecv(); 16 | }; 17 | 18 | Polling.prototype._scheduleRecv = function() { 19 | var that = this; 20 | var poll = that.poll = new that.Receiver(that.recv_url, that.AjaxObject); 21 | var msg_counter = 0; 22 | poll.onmessage = function(e) { 23 | msg_counter += 1; 24 | that.ri._didMessage(e.data); 25 | }; 26 | poll.onclose = function(e) { 27 | that.poll = poll = poll.onmessage = poll.onclose = null; 28 | if (!that.poll_is_closing) { 29 | if (e.reason === 'permanent') { 30 | that.ri._didClose(1006, 'Polling error (' + e.reason + ')'); 31 | } else { 32 | that._scheduleRecv(); 33 | } 34 | } 35 | }; 36 | }; 37 | 38 | Polling.prototype.abort = function() { 39 | var that = this; 40 | that.poll_is_closing = true; 41 | if (that.poll) { 42 | that.poll.abort(); 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-eventsource.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var EventSourceReceiver = function(url) { 10 | var that = this; 11 | var es = new EventSource(url); 12 | es.onmessage = function(e) { 13 | that.dispatchEvent(new SimpleEvent('message', 14 | {'data': unescape(e.data)})); 15 | }; 16 | that.es_close = es.onerror = function(e, abort_reason) { 17 | // ES on reconnection has readyState = 0 or 1. 18 | // on network error it's CLOSED = 2 19 | var reason = abort_reason ? 'user' : 20 | (es.readyState !== 2 ? 'network' : 'permanent'); 21 | that.es_close = es.onmessage = es.onerror = null; 22 | // EventSource reconnects automatically. 23 | es.close(); 24 | es = null; 25 | // Safari and chrome < 15 crash if we close window before 26 | // waiting for ES cleanup. See: 27 | // https://code.google.com/p/chromium/issues/detail?id=89155 28 | utils.delay(200, function() { 29 | that.dispatchEvent(new SimpleEvent('close', {reason: reason})); 30 | }); 31 | }; 32 | }; 33 | 34 | EventSourceReceiver.prototype = new REventTarget(); 35 | 36 | EventSourceReceiver.prototype.abort = function() { 37 | var that = this; 38 | if (that.es_close) { 39 | that.es_close({}, true); 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-htmlfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var _is_ie_htmlfile_capable; 10 | var isIeHtmlfileCapable = function() { 11 | if (_is_ie_htmlfile_capable === undefined) { 12 | if ('ActiveXObject' in _window) { 13 | try { 14 | _is_ie_htmlfile_capable = !!new ActiveXObject('htmlfile'); 15 | } catch (x) {} 16 | } else { 17 | _is_ie_htmlfile_capable = false; 18 | } 19 | } 20 | return _is_ie_htmlfile_capable; 21 | }; 22 | 23 | 24 | var HtmlfileReceiver = function(url) { 25 | var that = this; 26 | utils.polluteGlobalNamespace(); 27 | 28 | that.id = 'a' + utils.random_string(6, 26); 29 | url += ((url.indexOf('?') === -1) ? '?' : '&') + 30 | 'c=' + escape(WPrefix + '.' + that.id); 31 | 32 | var constructor = isIeHtmlfileCapable() ? 33 | utils.createHtmlfile : utils.createIframe; 34 | 35 | var iframeObj; 36 | _window[WPrefix][that.id] = { 37 | start: function () { 38 | iframeObj.loaded(); 39 | }, 40 | message: function (data) { 41 | that.dispatchEvent(new SimpleEvent('message', {'data': data})); 42 | }, 43 | stop: function () { 44 | that.iframe_close({}, 'network'); 45 | } 46 | }; 47 | that.iframe_close = function(e, abort_reason) { 48 | iframeObj.cleanup(); 49 | that.iframe_close = iframeObj = null; 50 | delete _window[WPrefix][that.id]; 51 | that.dispatchEvent(new SimpleEvent('close', {reason: abort_reason})); 52 | }; 53 | iframeObj = constructor(url, function(e) { 54 | that.iframe_close({}, 'permanent'); 55 | }); 56 | }; 57 | 58 | HtmlfileReceiver.prototype = new REventTarget(); 59 | 60 | HtmlfileReceiver.prototype.abort = function() { 61 | var that = this; 62 | if (that.iframe_close) { 63 | that.iframe_close({}, 'user'); 64 | } 65 | }; 66 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-receiver-xhr.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var XhrReceiver = function(url, AjaxObject) { 10 | var that = this; 11 | var buf_pos = 0; 12 | 13 | that.xo = new AjaxObject('POST', url, null); 14 | that.xo.onchunk = function(status, text) { 15 | if (status !== 200) return; 16 | while (1) { 17 | var buf = text.slice(buf_pos); 18 | var p = buf.indexOf('\n'); 19 | if (p === -1) break; 20 | buf_pos += p+1; 21 | var msg = buf.slice(0, p); 22 | that.dispatchEvent(new SimpleEvent('message', {data: msg})); 23 | } 24 | }; 25 | that.xo.onfinish = function(status, text) { 26 | that.xo.onchunk(status, text); 27 | that.xo = null; 28 | var reason = status === 200 ? 'network' : 'permanent'; 29 | that.dispatchEvent(new SimpleEvent('close', {reason: reason})); 30 | } 31 | }; 32 | 33 | XhrReceiver.prototype = new REventTarget(); 34 | 35 | XhrReceiver.prototype.abort = function() { 36 | var that = this; 37 | if (that.xo) { 38 | that.xo.close(); 39 | that.dispatchEvent(new SimpleEvent('close', {reason: 'user'})); 40 | that.xo = null; 41 | } 42 | }; 43 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-websocket.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var WebSocketTransport = SockJS.websocket = function(ri, trans_url) { 10 | var that = this; 11 | var url = trans_url + '/websocket'; 12 | if (url.slice(0, 5) === 'https') { 13 | url = 'wss' + url.slice(5); 14 | } else { 15 | url = 'ws' + url.slice(4); 16 | } 17 | that.ri = ri; 18 | that.url = url; 19 | var Constructor = _window.WebSocket || _window.MozWebSocket; 20 | 21 | that.ws = new Constructor(that.url); 22 | that.ws.onmessage = function(e) { 23 | that.ri._didMessage(e.data); 24 | }; 25 | // Firefox has an interesting bug. If a websocket connection is 26 | // created after onbeforeunload, it stays alive even when user 27 | // navigates away from the page. In such situation let's lie - 28 | // let's not open the ws connection at all. See: 29 | // https://github.com/sockjs/sockjs-client/issues/28 30 | // https://bugzilla.mozilla.org/show_bug.cgi?id=696085 31 | that.unload_ref = utils.unload_add(function(){that.ws.close()}); 32 | that.ws.onclose = function() { 33 | that.ri._didMessage(utils.closeFrame(1006, "WebSocket connection broken")); 34 | }; 35 | }; 36 | 37 | WebSocketTransport.prototype.doSend = function(data) { 38 | this.ws.send('[' + data + ']'); 39 | }; 40 | 41 | WebSocketTransport.prototype.doCleanup = function() { 42 | var that = this; 43 | var ws = that.ws; 44 | if (ws) { 45 | ws.onmessage = ws.onclose = null; 46 | ws.close(); 47 | utils.unload_del(that.unload_ref); 48 | that.unload_ref = that.ri = that.ws = null; 49 | } 50 | }; 51 | 52 | WebSocketTransport.enabled = function() { 53 | return !!(_window.WebSocket || _window.MozWebSocket); 54 | }; 55 | 56 | // In theory, ws should require 1 round trip. But in chrome, this is 57 | // not very stable over SSL. Most likely a ws connection requires a 58 | // separate SSL connection, in which case 2 round trips are an 59 | // absolute minumum. 60 | WebSocketTransport.roundTrips = 2; 61 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/lib/trans-xhr.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ***** BEGIN LICENSE BLOCK ***** 3 | * Copyright (c) 2011-2012 VMware, Inc. 4 | * 5 | * For the license see COPYING. 6 | * ***** END LICENSE BLOCK ***** 7 | */ 8 | 9 | var AjaxBasedTransport = function() {}; 10 | AjaxBasedTransport.prototype = new BufferedSender(); 11 | 12 | AjaxBasedTransport.prototype.run = function(ri, trans_url, 13 | url_suffix, Receiver, AjaxObject) { 14 | var that = this; 15 | that.ri = ri; 16 | that.trans_url = trans_url; 17 | that.send_constructor(createAjaxSender(AjaxObject)); 18 | that.poll = new Polling(ri, Receiver, 19 | trans_url + url_suffix, AjaxObject); 20 | }; 21 | 22 | AjaxBasedTransport.prototype.doCleanup = function() { 23 | var that = this; 24 | if (that.poll) { 25 | that.poll.abort(); 26 | that.poll = null; 27 | } 28 | }; 29 | 30 | // xhr-streaming 31 | var XhrStreamingTransport = SockJS['xhr-streaming'] = function(ri, trans_url) { 32 | this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject); 33 | }; 34 | 35 | XhrStreamingTransport.prototype = new AjaxBasedTransport(); 36 | 37 | XhrStreamingTransport.enabled = function() { 38 | // Support for CORS Ajax aka Ajax2? Opera 12 claims CORS but 39 | // doesn't do streaming. 40 | return (_window.XMLHttpRequest && 41 | 'withCredentials' in new XMLHttpRequest() && 42 | (!/opera/i.test(navigator.userAgent))); 43 | }; 44 | XhrStreamingTransport.roundTrips = 2; // preflight, ajax 45 | 46 | // Safari gets confused when a streaming ajax request is started 47 | // before onload. This causes the load indicator to spin indefinetely. 48 | XhrStreamingTransport.need_body = true; 49 | 50 | 51 | // According to: 52 | // http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests 53 | // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/ 54 | 55 | 56 | // xdr-streaming 57 | var XdrStreamingTransport = SockJS['xdr-streaming'] = function(ri, trans_url) { 58 | this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XDRObject); 59 | }; 60 | 61 | XdrStreamingTransport.prototype = new AjaxBasedTransport(); 62 | 63 | XdrStreamingTransport.enabled = function() { 64 | return !!_window.XDomainRequest; 65 | }; 66 | XdrStreamingTransport.roundTrips = 2; // preflight, ajax 67 | 68 | 69 | 70 | // xhr-polling 71 | var XhrPollingTransport = SockJS['xhr-polling'] = function(ri, trans_url) { 72 | this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRCorsObject); 73 | }; 74 | 75 | XhrPollingTransport.prototype = new AjaxBasedTransport(); 76 | 77 | XhrPollingTransport.enabled = XhrStreamingTransport.enabled; 78 | XhrPollingTransport.roundTrips = 2; // preflight, ajax 79 | 80 | 81 | // xdr-polling 82 | var XdrPollingTransport = SockJS['xdr-polling'] = function(ri, trans_url) { 83 | this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XDRObject); 84 | }; 85 | 86 | XdrPollingTransport.prototype = new AjaxBasedTransport(); 87 | 88 | XdrPollingTransport.enabled = XdrStreamingTransport.enabled; 89 | XdrPollingTransport.roundTrips = 2; // preflight, ajax 90 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs-client", 3 | "author": { 4 | "name": "Marek Majkowski" 5 | }, 6 | "version": "0.0.0-unreleasable", 7 | "description": "SockJS-client is a browser JavaScript library that provides a WebSocket-like object. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.", 8 | "keywords": [ 9 | "websockets", 10 | "websocket" 11 | ], 12 | "homepage": "http://sockjs.org", 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/sockjs/sockjs-client.git" 16 | }, 17 | "devDependencies": { 18 | "uglify-js": "1.2.5", 19 | "coffee-script": "1.2.x", 20 | "optparse": "1.0.3", 21 | "node-static": "0.5.9" 22 | }, 23 | "main": "sockjs.js", 24 | "_npmUser": { 25 | "name": "maxogden", 26 | "email": "max@maxogden.com" 27 | }, 28 | "_id": "sockjs-client@0.0.0-unreleasable", 29 | "dependencies": {}, 30 | "optionalDependencies": {}, 31 | "engines": { 32 | "node": "*" 33 | }, 34 | "_engineSupported": true, 35 | "_npmVersion": "1.1.21", 36 | "_nodeVersion": "v0.6.18", 37 | "_defaultsLoaded": true, 38 | "dist": { 39 | "shasum": "d927a9dfb205d9519791822de097dac57b7bd5a7" 40 | }, 41 | "_from": "sockjs-client@git://github.com/substack/sockjs-client.git#browserify-npm" 42 | } 43 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs-client/version: -------------------------------------------------------------------------------- 1 | 0.3.1 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/.npmignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | lib/.placeholder 3 | VERSION-GEN 4 | src 5 | node_modules 6 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/.pidfile.pid: -------------------------------------------------------------------------------- 1 | 15238 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/COPYING: -------------------------------------------------------------------------------- 1 | Parts of the code are derived from various open source projects. 2 | 3 | For code derived from Socket.IO by Guillermo Rauch see 4 | https://github.com/LearnBoost/socket.io/tree/0.6.17#readme. 5 | 6 | All other code is released on MIT license, see LICENSE-MIT-SockJS. 7 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/LICENSE-MIT-SockJS: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 VMware, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all serve clean 2 | 3 | COFFEE:=./node_modules/.bin/coffee 4 | 5 | #### General 6 | 7 | all: build 8 | 9 | build: src/*coffee 10 | @$(COFFEE) -v > /dev/null 11 | $(COFFEE) -o lib/ -c src/*.coffee 12 | 13 | clean: 14 | rm -f lib/*.js 15 | 16 | 17 | #### Testing 18 | 19 | test_server: 20 | node examples/test_server/server.js 21 | 22 | serve: 23 | @if [ -e .pidfile.pid ]; then \ 24 | kill `cat .pidfile.pid`; \ 25 | rm .pidfile.pid; \ 26 | fi 27 | 28 | @while [ 1 ]; do \ 29 | make build; \ 30 | echo " [*] Running http server"; \ 31 | make test_server & \ 32 | SRVPID=$$!; \ 33 | echo $$SRVPID > .pidfile.pid; \ 34 | echo " [*] Server pid: $$SRVPID"; \ 35 | inotifywait -r -q -e modify .; \ 36 | kill `cat .pidfile.pid`; \ 37 | rm -f .pidfile.pid; \ 38 | sleep 0.1; \ 39 | done 40 | 41 | #### Release process 42 | # 1) commit everything 43 | # 2) amend version in package.json 44 | # 3) run 'make tag' and run suggested 'git push' variants 45 | # 4) run 'npm publish' 46 | 47 | RVER:=$(shell grep "version" package.json|tr '\t"' ' \t'|cut -f 4) 48 | VER:=$(shell ./VERSION-GEN) 49 | 50 | .PHONY: tag 51 | tag: all 52 | git commit $(TAG_OPTS) package.json Changelog -m "Release $(RVER)" 53 | git tag -s v$(RVER) -m "Release $(RVER)" 54 | @echo ' [*] Now run' 55 | @echo 'git push; git push --tag' 56 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/echo/README.md: -------------------------------------------------------------------------------- 1 | SockJS-node Echo example 2 | ======================== 3 | 4 | To run this example, first install dependencies: 5 | 6 | npm install 7 | 8 | And run a server: 9 | 10 | node server.js 11 | 12 | 13 | That will spawn an http server at http://127.0.0.1:9999/ which will 14 | serve both html (served from the current directory) and also SockJS 15 | server (under the [/echo](http://127.0.0.1:9999/echo) path). 16 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/echo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 35 | 36 |

SockJS Echo example

37 | 38 |
39 |
40 |
41 |
42 | 43 | 71 | 72 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/echo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs-echo", 3 | "version": "0.0.0-unreleasable", 4 | "dependencies": { 5 | "node-static": "0.5.9", 6 | "sockjs": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/echo/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var sockjs = require('sockjs'); 3 | var node_static = require('node-static'); 4 | 5 | // 1. Echo sockjs server 6 | var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"}; 7 | 8 | var sockjs_echo = sockjs.createServer(sockjs_opts); 9 | sockjs_echo.on('connection', function(conn) { 10 | conn.on('data', function(message) { 11 | conn.write(message); 12 | }); 13 | }); 14 | 15 | // 2. Static files server 16 | var static_directory = new node_static.Server(__dirname); 17 | 18 | // 3. Usual http stuff 19 | var server = http.createServer(); 20 | server.addListener('request', function(req, res) { 21 | static_directory.serve(req, res); 22 | }); 23 | server.addListener('upgrade', function(req,res){ 24 | res.end(); 25 | }); 26 | 27 | sockjs_echo.installHandlers(server, {prefix:'/echo'}); 28 | 29 | console.log(' [*] Listening on 0.0.0.0:9999' ); 30 | server.listen(9999, '0.0.0.0'); 31 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/express/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 35 | 36 |

SockJS Express example

37 | 38 |
39 |
40 |
41 |
42 | 43 | 71 | 72 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/express/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs-express", 3 | "version": "0.0.0-unreleasable", 4 | "dependencies": { 5 | "express": "2.5.8", 6 | "sockjs": "*" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/express/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var sockjs = require('sockjs'); 3 | 4 | // 1. Echo sockjs server 5 | var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"}; 6 | 7 | var sockjs_echo = sockjs.createServer(sockjs_opts); 8 | sockjs_echo.on('connection', function(conn) { 9 | conn.on('data', function(message) { 10 | conn.write(message); 11 | }); 12 | }); 13 | 14 | // 2. Express server 15 | var app = express.createServer(); 16 | sockjs_echo.installHandlers(app, {prefix:'/echo'}); 17 | 18 | console.log(' [*] Listening on 0.0.0.0:9999' ); 19 | app.listen(9999, '0.0.0.0'); 20 | 21 | app.get('/', function (req, res) { 22 | res.sendfile(__dirname + '/index.html'); 23 | }); 24 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/haproxy.cfg: -------------------------------------------------------------------------------- 1 | # Requires recent Haproxy to work with websockets (for example 1.4.16). 2 | defaults 3 | mode http 4 | # Set timeouts to your needs 5 | timeout client 5s 6 | timeout connect 5s 7 | timeout server 5s 8 | 9 | frontend all 0.0.0.0:8888 10 | mode http 11 | timeout client 120s 12 | 13 | option forwardfor 14 | # Fake connection:close, required in this setup. 15 | option http-server-close 16 | option http-pretend-keepalive 17 | 18 | acl is_sockjs path_beg /echo /broadcast /close 19 | acl is_stats path_beg /stats 20 | 21 | use_backend sockjs if is_sockjs 22 | use_backend stats if is_stats 23 | default_backend static 24 | 25 | 26 | backend sockjs 27 | # Load-balance according to hash created from first two 28 | # directories in url path. For example requests going to /1/ 29 | # should be handled by single server (assuming resource prefix is 30 | # one-level deep, like "/echo"). 31 | balance uri depth 2 32 | timeout server 120s 33 | server srv_sockjs1 127.0.0.1:9999 34 | # server srv_sockjs2 127.0.0.1:9998 35 | 36 | backend static 37 | balance roundrobin 38 | server srv_static 127.0.0.1:8000 39 | 40 | backend stats 41 | stats uri /stats 42 | stats enable 43 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/multiplex/README.md: -------------------------------------------------------------------------------- 1 | WebSocket-multiplex SockJS example 2 | ================================== 3 | 4 | This example is a copy of example from 5 | [websocket-multiplex](https://github.com/sockjs/websocket-multiplex/) 6 | project: 7 | 8 | * https://github.com/sockjs/websocket-multiplex/ 9 | 10 | 11 | To run this example, first install dependencies: 12 | 13 | npm install 14 | 15 | And run a server: 16 | 17 | node server.js 18 | 19 | 20 | That will spawn an http server at http://127.0.0.1:9999/ which will 21 | serve both html (served from the current directory) and also SockJS 22 | service (under the [/multiplex](http://127.0.0.1:9999/multiplex) 23 | path). 24 | 25 | With that set up, WebSocket-multiplex is able to push three virtual 26 | connections over a single SockJS connection. See the code for details. 27 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/multiplex/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 36 | 37 |

SockJS Multiplex example

38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 | 49 |
50 |
51 |
52 |
53 | 54 | 96 | 97 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/multiplex/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs-multiplex", 3 | "version": "0.0.0-unreleasable", 4 | "dependencies": { 5 | "express": "2.5.8", 6 | "sockjs": "*", 7 | "websocket-multiplex" : "0.1.x" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/multiplex/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var sockjs = require('sockjs'); 3 | 4 | var websocket_multiplex = require('websocket-multiplex'); 5 | 6 | 7 | // 1. Setup SockJS server 8 | var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"}; 9 | var service = sockjs.createServer(sockjs_opts); 10 | 11 | 12 | // 2. Setup multiplexing 13 | var multiplexer = new websocket_multiplex.MultiplexServer(service); 14 | 15 | var ann = multiplexer.registerChannel('ann'); 16 | ann.on('connection', function(conn) { 17 | conn.write('Ann says hi!'); 18 | conn.on('data', function(data) { 19 | conn.write('Ann nods: ' + data); 20 | }); 21 | }); 22 | 23 | var bob = multiplexer.registerChannel('bob'); 24 | bob.on('connection', function(conn) { 25 | conn.write('Bob doesn\'t agree.'); 26 | conn.on('data', function(data) { 27 | conn.write('Bob says no to: ' + data); 28 | }); 29 | }); 30 | 31 | var carl = multiplexer.registerChannel('carl'); 32 | carl.on('connection', function(conn) { 33 | conn.write('Carl says goodbye!'); 34 | // Explicitly cancel connection 35 | conn.end(); 36 | }); 37 | 38 | 39 | // 3. Express server 40 | var app = express.createServer(); 41 | service.installHandlers(app, {prefix:'/multiplex'}); 42 | 43 | console.log(' [*] Listening on 0.0.0.0:9999' ); 44 | app.listen(9999, '0.0.0.0'); 45 | 46 | app.get('/', function (req, res) { 47 | res.sendfile(__dirname + '/index.html'); 48 | }); 49 | 50 | app.get('/multiplex.js', function (req, res) { 51 | res.sendfile(__dirname + '/multiplex.js'); 52 | }); 53 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/test_server/README.md: -------------------------------------------------------------------------------- 1 | SockJS test server 2 | ================== 3 | 4 | In order to test sockjs server implementation the server needs to 5 | provide a standarized sockjs endpoint that will can used by various 6 | sockjs-related tests. For example by QUnit or 7 | [Sockjs-protocol](https://github.com/sockjs/sockjs-protocol) tests. 8 | 9 | This small code does exactly that - runs a simple server that supports 10 | the following SockJS services: 11 | 12 | * `/echo` 13 | * `/disabled_websocket_echo` 14 | * `/close` 15 | * `/ticker` 16 | * `/amplify` 17 | * `/broadcast` 18 | 19 | If you just want to quickly run it: 20 | 21 | npm install 22 | node server.js 23 | 24 | 25 | If you want to run do development it's recommended to run `make 26 | test_server` from the top `sockjs-node` directory: 27 | 28 | cd ../.. 29 | make test_server 30 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/test_server/config.js: -------------------------------------------------------------------------------- 1 | exports.config = { 2 | server_opts: { 3 | sockjs_url: 'http://localhost:8080/lib/sockjs.js', 4 | websocket: true 5 | }, 6 | 7 | port: 8081, 8 | host: '0.0.0.0' 9 | }; 10 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/test_server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs-test-server", 3 | "version": "0.0.0-unreleasable", 4 | "dependencies": { 5 | "sockjs": "*" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/test_server/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var config = require('./config').config; 3 | var sockjs_app = require('./sockjs_app'); 4 | 5 | 6 | var server = http.createServer(); 7 | server.addListener('request', function(req, res) { 8 | res.setHeader('content-type', 'text/plain'); 9 | res.writeHead(404); 10 | res.end('404 - Nothing here (via sockjs-node test_server)'); 11 | }); 12 | server.addListener('upgrade', function(req, res){ 13 | res.end(); 14 | }); 15 | 16 | sockjs_app.install(config.server_opts, server); 17 | 18 | console.log(" [*] Listening on", config.host + ':' + config.port); 19 | server.listen(config.port, config.host); 20 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/examples/test_server/sockjs_app.js: -------------------------------------------------------------------------------- 1 | var sockjs = require('sockjs'); 2 | 3 | exports.install = function(opts, server) { 4 | var sjs_echo = sockjs.createServer(opts); 5 | sjs_echo.on('connection', function(conn) { 6 | console.log(' [+] echo open ' + conn); 7 | conn.on('close', function() { 8 | console.log(' [-] echo close ' + conn); 9 | }); 10 | conn.on('data', function(m) { 11 | var d = JSON.stringify(m); 12 | console.log(' [ ] echo message ' + conn, 13 | d.slice(0,64)+ 14 | ((d.length > 64) ? '...' : '')); 15 | conn.write(m); 16 | }); 17 | }); 18 | 19 | var sjs_close = sockjs.createServer(opts); 20 | sjs_close.on('connection', function(conn) { 21 | console.log(' [+] clos open ' + conn); 22 | conn.close(3000, "Go away!"); 23 | conn.on('close', function() { 24 | console.log(' [-] clos close ' + conn); 25 | }); 26 | }); 27 | 28 | var sjs_ticker = sockjs.createServer(opts); 29 | sjs_ticker.on('connection', function(conn) { 30 | console.log(' [+] ticker open ' + conn); 31 | var tref; 32 | var schedule = function() { 33 | conn.write('tick!'); 34 | tref = setTimeout(schedule, 1000); 35 | }; 36 | tref = setTimeout(schedule, 1000); 37 | conn.on('close', function() { 38 | clearTimeout(tref); 39 | console.log(' [-] ticker close ' + conn); 40 | }); 41 | }); 42 | 43 | var broadcast = {}; 44 | var sjs_broadcast = sockjs.createServer(opts); 45 | sjs_broadcast.on('connection', function(conn) { 46 | console.log(' [+] broadcast open ' + conn); 47 | broadcast[conn.id] = conn; 48 | conn.on('close', function() { 49 | delete broadcast[conn.id]; 50 | console.log(' [-] broadcast close' + conn); 51 | }); 52 | conn.on('data', function(m) { 53 | console.log(' [-] broadcast message', m); 54 | for(var id in broadcast) { 55 | broadcast[id].write(m); 56 | } 57 | }); 58 | }); 59 | 60 | var sjs_amplify = sockjs.createServer(opts); 61 | sjs_amplify.on('connection', function(conn) { 62 | console.log(' [+] amp open ' + conn); 63 | conn.on('close', function() { 64 | console.log(' [-] amp close ' + conn); 65 | }); 66 | conn.on('data', function(m) { 67 | var n = Math.floor(Number(m)); 68 | n = (n > 0 && n < 19) ? n : 1; 69 | console.log(' [ ] amp message: 2^' + n); 70 | conn.write(Array(Math.pow(2, n)+1).join('x')); 71 | }); 72 | }); 73 | 74 | 75 | sjs_echo.installHandlers(server, {prefix:'/echo', 76 | response_limit: 4096}), 77 | sjs_echo.installHandlers(server, {prefix:'/disabled_websocket_echo', 78 | websocket: false}); 79 | sjs_echo.installHandlers(server, {prefix:'/cookie_needed_echo', 80 | jsessionid: true}); 81 | sjs_close.installHandlers(server, {prefix:'/close'}); 82 | sjs_ticker.installHandlers(server, {prefix:'/ticker'}); 83 | sjs_amplify.installHandlers(server, {prefix:'/amplify'}); 84 | sjs_broadcast.installHandlers(server, {prefix:'/broadcast'}); 85 | }; 86 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/sockjs'); 2 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/lib/chunking-test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var utils; 3 | 4 | utils = require('./utils'); 5 | 6 | exports.app = { 7 | chunking_test: function(req, res, _, next_filter) { 8 | var write, 9 | _this = this; 10 | res.setHeader('Content-Type', 'application/javascript; charset=UTF-8'); 11 | res.writeHead(200); 12 | write = function(payload) { 13 | try { 14 | return res.write(payload + '\n'); 15 | } catch (x) { 16 | 17 | } 18 | }; 19 | utils.timeout_chain([ 20 | [ 21 | 0, function() { 22 | return write('h'); 23 | } 24 | ], [ 25 | 1, function() { 26 | return write(Array(2049).join(' ') + 'h'); 27 | } 28 | ], [ 29 | 5, function() { 30 | return write('h'); 31 | } 32 | ], [ 33 | 25, function() { 34 | return write('h'); 35 | } 36 | ], [ 37 | 125, function() { 38 | return write('h'); 39 | } 40 | ], [ 41 | 625, function() { 42 | return write('h'); 43 | } 44 | ], [ 45 | 3125, function() { 46 | write('h'); 47 | return res.end(); 48 | } 49 | ] 50 | ]); 51 | return true; 52 | }, 53 | info: function(req, res, _) { 54 | var info; 55 | info = { 56 | websocket: this.options.websocket, 57 | origins: this.options.origins, 58 | cookie_needed: !!this.options.jsessionid, 59 | entropy: utils.random32() 60 | }; 61 | res.setHeader('Content-Type', 'application/json; charset=UTF-8'); 62 | res.writeHead(200); 63 | return res.end(JSON.stringify(info)); 64 | }, 65 | info_options: function(req, res) { 66 | res.statusCode = 204; 67 | res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET'); 68 | res.setHeader('Access-Control-Max-Age', res.cache_for); 69 | return ''; 70 | } 71 | }; 72 | 73 | }).call(this); 74 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/lib/iframe.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var iframe_template, utils; 3 | 4 | utils = require('./utils'); 5 | 6 | iframe_template = "\n\n\n \n \n \n \n\n\n

Don't panic!

\n

This is a SockJS hidden iframe. It's used for cross domain magic.

\n\n"; 7 | 8 | exports.app = { 9 | iframe: function(req, res) { 10 | var content, context, k, quoted_md5; 11 | context = { 12 | '{{ sockjs_url }}': this.options.sockjs_url 13 | }; 14 | content = iframe_template; 15 | for (k in context) { 16 | content = content.replace(k, context[k]); 17 | } 18 | quoted_md5 = '"' + utils.md5_hex(content) + '"'; 19 | if ('if-none-match' in req.headers && req.headers['if-none-match'] === quoted_md5) { 20 | res.statusCode = 304; 21 | return ''; 22 | } 23 | res.setHeader('Content-Type', 'text/html; charset=UTF-8'); 24 | res.setHeader('ETag', quoted_md5); 25 | return content; 26 | } 27 | }; 28 | 29 | }).call(this); 30 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/lib/trans-eventsource.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var EventSourceReceiver, transport, utils, 3 | __hasProp = Object.prototype.hasOwnProperty, 4 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; 5 | 6 | utils = require('./utils'); 7 | 8 | transport = require('./transport'); 9 | 10 | EventSourceReceiver = (function(_super) { 11 | 12 | __extends(EventSourceReceiver, _super); 13 | 14 | function EventSourceReceiver() { 15 | EventSourceReceiver.__super__.constructor.apply(this, arguments); 16 | } 17 | 18 | EventSourceReceiver.prototype.protocol = "eventsource"; 19 | 20 | EventSourceReceiver.prototype.doSendFrame = function(payload) { 21 | var data; 22 | data = ['data: ', utils.escape_selected(payload, '\r\n\x00'), '\r\n\r\n']; 23 | return EventSourceReceiver.__super__.doSendFrame.call(this, data.join('')); 24 | }; 25 | 26 | return EventSourceReceiver; 27 | 28 | })(transport.ResponseReceiver); 29 | 30 | exports.app = { 31 | eventsource: function(req, res) { 32 | res.setHeader('Content-Type', 'text/event-stream; charset=UTF-8'); 33 | res.writeHead(200); 34 | res.write('\r\n'); 35 | transport.register(req, this, new EventSourceReceiver(res, this.options)); 36 | return true; 37 | } 38 | }; 39 | 40 | }).call(this); 41 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/lib/trans-htmlfile.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HtmlFileReceiver, iframe_template, transport, utils, 3 | __hasProp = Object.prototype.hasOwnProperty, 4 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; 5 | 6 | utils = require('./utils'); 7 | 8 | transport = require('./transport'); 9 | 10 | iframe_template = "\n\n \n \n

Don't panic!

\n "; 11 | 12 | iframe_template += Array(1024 - iframe_template.length + 14).join(' '); 13 | 14 | iframe_template += '\r\n\r\n'; 15 | 16 | HtmlFileReceiver = (function(_super) { 17 | 18 | __extends(HtmlFileReceiver, _super); 19 | 20 | function HtmlFileReceiver() { 21 | HtmlFileReceiver.__super__.constructor.apply(this, arguments); 22 | } 23 | 24 | HtmlFileReceiver.prototype.protocol = "htmlfile"; 25 | 26 | HtmlFileReceiver.prototype.doSendFrame = function(payload) { 27 | return HtmlFileReceiver.__super__.doSendFrame.call(this, '\r\n'); 28 | }; 29 | 30 | return HtmlFileReceiver; 31 | 32 | })(transport.ResponseReceiver); 33 | 34 | exports.app = { 35 | htmlfile: function(req, res) { 36 | var callback; 37 | if (!('c' in req.query || 'callback' in req.query)) { 38 | throw { 39 | status: 500, 40 | message: '"callback" parameter required' 41 | }; 42 | } 43 | callback = 'c' in req.query ? req.query['c'] : req.query['callback']; 44 | if (/[^a-zA-Z0-9-_.]/.test(callback)) { 45 | throw { 46 | status: 500, 47 | message: 'invalid "callback" parameter' 48 | }; 49 | } 50 | res.setHeader('Content-Type', 'text/html; charset=UTF-8'); 51 | res.writeHead(200); 52 | res.write(iframe_template.replace(/{{ callback }}/g, callback)); 53 | transport.register(req, this, new HtmlFileReceiver(res, this.options)); 54 | return true; 55 | } 56 | }; 57 | 58 | }).call(this); 59 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | === 0.4.0 / 2012-02-13 2 | 3 | * Add ping() method to server-side WebSocket and EventSource 4 | * Buffer send() calls until the draft-76 handshake is complete 5 | * Fix HTTPS problems on Node 0.7 6 | 7 | 8 | === 0.3.1 / 2012-01-16 9 | 10 | * Call setNoDelay(true) on net.Socket objects to reduce latency 11 | 12 | 13 | === 0.3.0 / 2012-01-13 14 | 15 | * Add support for EventSource connections 16 | 17 | 18 | === 0.2.0 / 2011-12-21 19 | 20 | * Add support for Sec-WebSocket-Protocol negotiation 21 | * Support hixie-76 close frames and 75/76 ignored segments 22 | * Improve performance of HyBi parsing/framing functions 23 | * Decouple parsers from TCP and reduce write volume 24 | 25 | 26 | === 0.1.2 / 2011-12-05 27 | 28 | * Detect closed sockets on the server side when TCP connection breaks 29 | * Make hixie-76 sockets work through HAProxy 30 | 31 | 32 | === 0.1.1 / 2011-11-30 33 | 34 | * Fix addEventListener() interface methods 35 | 36 | 37 | === 0.1.0 / 2011-11-27 38 | 39 | * Initial release, based on WebSocket components from Faye 40 | 41 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/autobahn_client.js: -------------------------------------------------------------------------------- 1 | var WebSocket = require('../lib/faye/websocket'); 2 | 3 | var host = 'ws://localhost:9001', 4 | agent = 'Faye (Node ' + process.version + ')', 5 | cases = 0, 6 | skip = []; 7 | 8 | var socket = new WebSocket.Client(host + '/getCaseCount'); 9 | 10 | socket.onmessage = function(event) { 11 | console.log('Total cases to run: ' + event.data); 12 | cases = parseInt(event.data); 13 | }; 14 | 15 | socket.onclose = function() { 16 | var runCase = function(n) { 17 | if (n > cases) { 18 | socket = new WebSocket.Client(host + '/updateReports?agent=' + encodeURIComponent(agent)); 19 | socket.onclose = process.exit 20 | 21 | } else if (skip.indexOf(n) >= 0) { 22 | runCase(n + 1); 23 | 24 | } else { 25 | console.log('Running test case #' + n + ' ...'); 26 | socket = new WebSocket.Client(host + '/runCase?case=' + n + '&agent=' + encodeURIComponent(agent)); 27 | 28 | socket.onmessage = function(event) { 29 | socket.send(event.data); 30 | }; 31 | 32 | socket.onclose = function() { 33 | runCase(n + 1); 34 | }; 35 | } 36 | }; 37 | 38 | runCase(1); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/client.js: -------------------------------------------------------------------------------- 1 | var WebSocket = require('../lib/faye/websocket'), 2 | port = process.argv[2] || 7000, 3 | secure = process.argv[3] === 'ssl', 4 | scheme = secure ? 'wss' : 'ws', 5 | ws = new WebSocket.Client(scheme + '://localhost:' + port + '/'); 6 | 7 | console.log('Connecting to ' + ws.url); 8 | 9 | ws.onopen = function(event) { 10 | console.log('open'); 11 | ws.send('Hello, WebSocket!'); 12 | }; 13 | 14 | ws.onmessage = function(event) { 15 | console.log('message', event.data); 16 | // ws.close(1002, 'Going away'); 17 | }; 18 | 19 | ws.onclose = function(event) { 20 | console.log('close', event.code, event.reason); 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/haproxy.conf: -------------------------------------------------------------------------------- 1 | defaults 2 | mode http 3 | timeout client 5s 4 | timeout connect 5s 5 | timeout server 5s 6 | 7 | frontend all 0.0.0.0:3000 8 | mode http 9 | timeout client 120s 10 | 11 | option forwardfor 12 | option http-server-close 13 | option http-pretend-keepalive 14 | 15 | default_backend sockets 16 | 17 | backend sockets 18 | balance uri depth 2 19 | timeout server 120s 20 | server socket1 127.0.0.1:7000 21 | 22 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/server.js: -------------------------------------------------------------------------------- 1 | var WebSocket = require('../lib/faye/websocket'), 2 | fs = require('fs'), 3 | http = require('http'), 4 | https = require('https'); 5 | 6 | var port = process.argv[2] || 7000, 7 | secure = process.argv[3] === 'ssl'; 8 | 9 | var upgradeHandler = function(request, socket, head) { 10 | var ws = new WebSocket(request, socket, head, ['irc', 'xmpp'], {ping: 5}); 11 | console.log('open', ws.url, ws.version, ws.protocol); 12 | 13 | ws.onmessage = function(event) { 14 | ws.send(event.data); 15 | }; 16 | 17 | ws.onclose = function(event) { 18 | console.log('close', event.code, event.reason); 19 | ws = null; 20 | }; 21 | }; 22 | 23 | var requestHandler = function(request, response) { 24 | if (!WebSocket.EventSource.isEventSource(request)) 25 | return staticHandler(request, response); 26 | 27 | var es = new WebSocket.EventSource(request, response), 28 | time = parseInt(es.lastEventId, 10) || 0; 29 | 30 | console.log('open', es.url, es.lastEventId); 31 | 32 | var loop = setInterval(function() { 33 | time += 1; 34 | es.send('Time: ' + time); 35 | setTimeout(function() { 36 | if (es) es.send('Update!!', {event: 'update', id: time}); 37 | }, 1000); 38 | }, 2000); 39 | 40 | es.send('Welcome!\n\nThis is an EventSource server.'); 41 | 42 | es.onclose = function() { 43 | clearInterval(loop); 44 | console.log('close', es.url); 45 | es = null; 46 | }; 47 | }; 48 | 49 | var staticHandler = function(request, response) { 50 | var path = request.url; 51 | 52 | fs.readFile(__dirname + path, function(err, content) { 53 | var status = err ? 404 : 200; 54 | response.writeHead(status, {'Content-Type': 'text/html'}); 55 | response.write(content || 'Not found'); 56 | response.end(); 57 | }); 58 | }; 59 | 60 | var server = secure 61 | ? https.createServer({ 62 | key: fs.readFileSync(__dirname + '/../spec/server.key'), 63 | cert: fs.readFileSync(__dirname + '/../spec/server.crt') 64 | }) 65 | : http.createServer(); 66 | 67 | server.addListener('request', requestHandler); 68 | server.addListener('upgrade', upgradeHandler); 69 | server.listen(port); 70 | 71 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/sse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | EventSource test 6 | 7 | 8 | 9 |

EventSource test

10 | 11 | 12 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/examples/ws.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WebSocket test 6 | 7 | 8 | 9 |

WebSocket test

10 | 11 | 12 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/api.js: -------------------------------------------------------------------------------- 1 | var EventTarget = require('./api/event_target'), 2 | Event = require('./api/event'); 3 | 4 | var API = { 5 | CONNECTING: 0, 6 | OPEN: 1, 7 | CLOSING: 2, 8 | CLOSED: 3, 9 | 10 | _open: function() { 11 | if (this._parser && !this._parser.isOpen()) return; 12 | this.readyState = API.OPEN; 13 | 14 | var buffer = this._sendBuffer || [], 15 | message; 16 | 17 | while (message = buffer.shift()) 18 | this.send.apply(this, message); 19 | 20 | var event = new Event('open'); 21 | event.initEvent('open', false, false); 22 | this.dispatchEvent(event); 23 | }, 24 | 25 | receive: function(data) { 26 | if (this.readyState !== API.OPEN) return false; 27 | var event = new Event('message'); 28 | event.initEvent('message', false, false); 29 | event.data = data; 30 | this.dispatchEvent(event); 31 | }, 32 | 33 | send: function(data, type, errorType) { 34 | if (this.readyState === API.CONNECTING) { 35 | if (this._sendBuffer) { 36 | this._sendBuffer.push(arguments); 37 | return true; 38 | } else { 39 | throw new Error('Cannot call send(), socket is not open yet'); 40 | } 41 | } 42 | 43 | if (this.readyState === API.CLOSED) 44 | return false; 45 | 46 | var frame = this._parser.frame(data, type, errorType); 47 | try { 48 | this._stream.write(frame, 'binary'); 49 | return true; 50 | } catch (e) { 51 | return false; 52 | } 53 | }, 54 | 55 | close: function(code, reason, ack) { 56 | if (this.readyState === API.CLOSING || 57 | this.readyState === API.CLOSED) return; 58 | 59 | this.readyState = API.CLOSING; 60 | 61 | var close = function() { 62 | this.readyState = API.CLOSED; 63 | if (this._pingLoop) clearInterval(this._pingLoop); 64 | this._stream.end(); 65 | var event = new Event('close', {code: code || 1000, reason: reason || ''}); 66 | event.initEvent('close', false, false); 67 | this.dispatchEvent(event); 68 | }; 69 | 70 | if (ack !== false) { 71 | if (this._parser.close) this._parser.close(code, reason, close, this); 72 | else close.call(this); 73 | } else { 74 | if (this._parser.close) this._parser.close(code, reason); 75 | close.call(this); 76 | } 77 | } 78 | }; 79 | 80 | for (var key in EventTarget) API[key] = EventTarget[key]; 81 | 82 | module.exports = API; 83 | 84 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/api/event.js: -------------------------------------------------------------------------------- 1 | var Event = function(eventType, options) { 2 | this.type = eventType; 3 | for (var key in options) 4 | this[key] = options[key]; 5 | }; 6 | 7 | Event.prototype.initEvent = function(eventType, canBubble, cancelable) { 8 | this.type = eventType; 9 | this.bubbles = canBubble; 10 | this.cancelable = cancelable; 11 | }; 12 | 13 | Event.prototype.stopPropagation = function() {}; 14 | Event.prototype.preventDefault = function() {}; 15 | 16 | Event.CAPTURING_PHASE = 1; 17 | Event.AT_TARGET = 2; 18 | Event.BUBBLING_PHASE = 3; 19 | 20 | module.exports = Event; 21 | 22 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js: -------------------------------------------------------------------------------- 1 | var Event = require('./event'); 2 | 3 | var EventTarget = { 4 | onopen: null, 5 | onmessage: null, 6 | onerror: null, 7 | onclose: null, 8 | 9 | addEventListener: function(eventType, listener, useCapture) { 10 | this._listeners = this._listeners || {}; 11 | var list = this._listeners[eventType] = this._listeners[eventType] || []; 12 | list.push(listener); 13 | }, 14 | 15 | removeEventListener: function(eventType, listener, useCapture) { 16 | if (!this._listeners || !this._listeners[eventType]) return; 17 | 18 | if (!listener) { 19 | delete this._listeners[eventType]; 20 | return; 21 | } 22 | var list = this._listeners[eventType], 23 | i = list.length; 24 | 25 | while (i--) { 26 | if (listener !== list[i]) continue; 27 | list.splice(i,1); 28 | } 29 | }, 30 | 31 | dispatchEvent: function(event) { 32 | event.target = event.currentTarget = this; 33 | event.eventPhase = Event.AT_TARGET; 34 | 35 | if (this['on' + event.type]) 36 | this['on' + event.type](event); 37 | 38 | if (!this._listeners || !this._listeners[event.type]) return; 39 | 40 | this._listeners[event.type].forEach(function(listener) { 41 | listener(event); 42 | }, this); 43 | } 44 | }; 45 | 46 | module.exports = EventTarget; 47 | 48 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/client.js: -------------------------------------------------------------------------------- 1 | var net = require('net'), 2 | tls = require('tls'); 3 | 4 | var HybiParser = require('./hybi_parser'), 5 | API = require('./api'), 6 | Event = require('./api/event'); 7 | 8 | var Client = function(url, protocols) { 9 | this.url = url; 10 | this._uri = require('url').parse(url); 11 | 12 | this.protocol = ''; 13 | this.readyState = API.CONNECTING; 14 | this.bufferedAmount = 0; 15 | 16 | var secure = (this._uri.protocol === 'wss:'), 17 | self = this, 18 | onConnect = function() { self._onConnect() }, 19 | 20 | connection = secure 21 | ? tls.connect(this._uri.port || 443, this._uri.hostname, {}, onConnect) 22 | : net.createConnection(this._uri.port || 80, this._uri.hostname); 23 | 24 | this._parser = new HybiParser(this, {masking: true, protocols: protocols}); 25 | this._stream = connection; 26 | 27 | this._stream.setTimeout(0); 28 | this._stream.setNoDelay(true); 29 | 30 | if (!secure) connection.addListener('connect', onConnect); 31 | 32 | connection.addListener('data', function(data) { 33 | self._onData(data); 34 | }); 35 | ['close', 'end', 'error'].forEach(function(event) { 36 | connection.addListener(event, function() { self.close(1006, '', false) }); 37 | }); 38 | }; 39 | 40 | Client.prototype._onConnect = function() { 41 | this._handshake = this._parser.createHandshake(this._uri, this._stream); 42 | this._message = []; 43 | try { 44 | this._stream.write(this._handshake.requestData(), 'binary'); 45 | } catch (e) {} 46 | }; 47 | 48 | Client.prototype._onData = function(data) { 49 | switch (this.readyState) { 50 | case API.CONNECTING: 51 | var bytes = this._handshake.parse(data); 52 | for (var i = 0, n = bytes.length; i < n; i++) 53 | this._message.push(bytes[i]); 54 | 55 | if (!this._handshake.isComplete()) return; 56 | 57 | if (this._handshake.isValid()) { 58 | this.protocol = this._handshake.protocol || ''; 59 | this.readyState = API.OPEN; 60 | var event = new Event('open'); 61 | event.initEvent('open', false, false); 62 | this.dispatchEvent(event); 63 | 64 | this._parser.parse(this._message); 65 | 66 | } else { 67 | this.readyState = API.CLOSED; 68 | var event = new Event('close', {code: 1006, reason: ''}); 69 | event.initEvent('close', false, false); 70 | this.dispatchEvent(event); 71 | } 72 | break; 73 | 74 | case API.OPEN: 75 | case API.CLOSING: 76 | this._parser.parse(data); 77 | } 78 | }; 79 | 80 | for (var key in API) Client.prototype[key] = API[key]; 81 | 82 | module.exports = Client; 83 | 84 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/draft75_parser.js: -------------------------------------------------------------------------------- 1 | var Draft75Parser = function(webSocket) { 2 | this._socket = webSocket; 3 | this._stage = 0; 4 | }; 5 | 6 | var instance = { 7 | getVersion: function() { 8 | return 'hixie-75'; 9 | }, 10 | 11 | handshakeResponse: function() { 12 | return new Buffer('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + 13 | 'Upgrade: WebSocket\r\n' + 14 | 'Connection: Upgrade\r\n' + 15 | 'WebSocket-Origin: ' + this._socket.request.headers.origin + '\r\n' + 16 | 'WebSocket-Location: ' + this._socket.url + '\r\n\r\n', 17 | 'utf8'); 18 | }, 19 | 20 | isOpen: function() { 21 | return true; 22 | }, 23 | 24 | parse: function(buffer) { 25 | var data, message, value; 26 | for (var i = 0, n = buffer.length; i < n; i++) { 27 | data = buffer[i]; 28 | 29 | switch (this._stage) { 30 | case 0: 31 | this._parseLeadingByte(data); 32 | break; 33 | 34 | case 1: 35 | value = (data & 0x7F); 36 | this._length = value + 128 * this._length; 37 | 38 | if (this._closing && this._length === 0) { 39 | this._socket.close(null, null, false); 40 | } 41 | else if ((0x80 & data) !== 0x80) { 42 | if (this._length === 0) { 43 | this._socket.receive(''); 44 | this._stage = 0; 45 | } 46 | else { 47 | this._buffer = []; 48 | this._stage = 2; 49 | } 50 | } 51 | break; 52 | 53 | case 2: 54 | if (data === 0xFF) { 55 | message = new Buffer(this._buffer); 56 | this._socket.receive(message.toString('utf8', 0, this._buffer.length)); 57 | this._stage = 0; 58 | } 59 | else { 60 | this._buffer.push(data); 61 | if (this._length && this._buffer.length === this._length) 62 | this._stage = 0; 63 | } 64 | break; 65 | } 66 | } 67 | }, 68 | 69 | _parseLeadingByte: function(data) { 70 | if ((0x80 & data) === 0x80) { 71 | this._length = 0; 72 | this._stage = 1; 73 | } else { 74 | delete this._length; 75 | this._buffer = []; 76 | this._stage = 2; 77 | } 78 | }, 79 | 80 | frame: function(data) { 81 | if (Buffer.isBuffer(data)) return data; 82 | 83 | var buffer = new Buffer(data, 'utf8'), 84 | frame = new Buffer(buffer.length + 2); 85 | 86 | frame[0] = 0x00; 87 | frame[buffer.length + 1] = 0xFF; 88 | buffer.copy(frame, 1); 89 | 90 | return frame; 91 | } 92 | }; 93 | 94 | for (var key in instance) 95 | Draft75Parser.prototype[key] = instance[key]; 96 | 97 | module.exports = Draft75Parser; 98 | 99 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/draft76_parser.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'), 2 | Draft75Parser = require('./draft75_parser'), 3 | Draft76Parser = function() { Draft75Parser.apply(this, arguments) }; 4 | 5 | var bridge = function() {}; 6 | bridge.prototype = Draft75Parser.prototype; 7 | Draft76Parser.prototype = new bridge(); 8 | 9 | var numberFromKey = function(key) { 10 | return parseInt(key.match(/[0-9]/g).join(''), 10); 11 | }; 12 | 13 | var spacesInKey = function(key) { 14 | return key.match(/ /g).length; 15 | }; 16 | 17 | var bigEndian = function(number) { 18 | var string = ''; 19 | [24,16,8,0].forEach(function(offset) { 20 | string += String.fromCharCode(number >> offset & 0xFF); 21 | }); 22 | return string; 23 | }; 24 | 25 | Draft76Parser.prototype.getVersion = function() { 26 | return 'hixie-76'; 27 | }; 28 | 29 | Draft76Parser.prototype.handshakeResponse = function(head) { 30 | var request = this._socket.request, tmp; 31 | 32 | var response = new Buffer('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + 33 | 'Upgrade: WebSocket\r\n' + 34 | 'Connection: Upgrade\r\n' + 35 | 'Sec-WebSocket-Origin: ' + request.headers.origin + '\r\n' + 36 | 'Sec-WebSocket-Location: ' + this._socket.url + '\r\n\r\n', 37 | 'binary'); 38 | 39 | var signature = this.handshakeSignature(head); 40 | if (signature) { 41 | tmp = new Buffer(response.length + signature.length); 42 | response.copy(tmp, 0); 43 | signature.copy(tmp, response.length); 44 | response = tmp; 45 | } 46 | 47 | return response; 48 | }; 49 | 50 | Draft76Parser.prototype.isOpen = function() { 51 | return !!this._handshakeComplete; 52 | }; 53 | 54 | Draft76Parser.prototype.handshakeSignature = function(head) { 55 | if (head.length === 0) return null; 56 | 57 | var request = this._socket.request, 58 | 59 | key1 = request.headers['sec-websocket-key1'], 60 | value1 = numberFromKey(key1) / spacesInKey(key1), 61 | 62 | key2 = request.headers['sec-websocket-key2'], 63 | value2 = numberFromKey(key2) / spacesInKey(key2), 64 | 65 | MD5 = crypto.createHash('md5'); 66 | 67 | MD5.update(bigEndian(value1)); 68 | MD5.update(bigEndian(value2)); 69 | MD5.update(head.toString('binary')); 70 | 71 | this._handshakeComplete = true; 72 | return new Buffer(MD5.digest('binary'), 'binary'); 73 | }; 74 | 75 | Draft76Parser.prototype.parse = function(data) { 76 | if (this._handshakeComplete) 77 | return Draft75Parser.prototype.parse.call(this, data); 78 | 79 | return this.handshakeSignature(data); 80 | }; 81 | 82 | Draft76Parser.prototype._parseLeadingByte = function(data) { 83 | if (data !== 0xFF) 84 | return Draft75Parser.prototype._parseLeadingByte.call(this, data); 85 | 86 | this._closing = true; 87 | this._length = 0; 88 | this._stage = 1; 89 | }; 90 | 91 | Draft76Parser.prototype.close = function(code, reason, callback, context) { 92 | if (this._closed) return; 93 | if (this._closing) this._socket.send(new Buffer([0xFF, 0x00])); 94 | this._closed = true; 95 | if (callback) callback.call(context); 96 | }; 97 | 98 | module.exports = Draft76Parser; 99 | 100 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/hybi_parser/handshake.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'); 2 | 3 | var Handshake = function(uri, protocols) { 4 | this._uri = uri; 5 | this._protocols = protocols; 6 | 7 | var buffer = new Buffer(16), i = 16; 8 | while (i--) buffer[i] = Math.floor(Math.random() * 256); 9 | this._key = buffer.toString('base64'); 10 | 11 | var SHA1 = crypto.createHash('sha1'); 12 | SHA1.update(this._key + Handshake.GUID); 13 | this._accept = SHA1.digest('base64'); 14 | 15 | var HTTPParser = process.binding('http_parser').HTTPParser, 16 | parser = new HTTPParser(HTTPParser.RESPONSE || 'response'), 17 | current = null, 18 | self = this; 19 | 20 | this._nodeVersion = HTTPParser.RESPONSE ? 6 : 4; 21 | this._complete = false; 22 | this._headers = {}; 23 | this._parser = parser; 24 | 25 | parser.onHeaderField = function(b, start, length) { 26 | current = b.toString('utf8', start, start + length); 27 | }; 28 | parser.onHeaderValue = function(b, start, length) { 29 | self._headers[current] = b.toString('utf8', start, start + length); 30 | }; 31 | parser.onHeadersComplete = function(info) { 32 | self._status = info.statusCode; 33 | var headers = info.headers; 34 | if (!headers) return; 35 | for (var i = 0, n = headers.length; i < n; i += 2) 36 | self._headers[headers[i]] = headers[i+1]; 37 | }; 38 | parser.onMessageComplete = function() { 39 | self._complete = true; 40 | }; 41 | }; 42 | 43 | Handshake.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'; 44 | 45 | Handshake.prototype.requestData = function() { 46 | var u = this._uri; 47 | 48 | var headers = [ 49 | 'GET ' + u.pathname + (u.search || '') + ' HTTP/1.1', 50 | 'Host: ' + u.hostname + (u.port ? ':' + u.port : ''), 51 | 'Upgrade: websocket', 52 | 'Connection: Upgrade', 53 | 'Sec-WebSocket-Key: ' + this._key, 54 | 'Sec-WebSocket-Version: 13' 55 | ]; 56 | 57 | if (this._protocols) 58 | headers.push('Sec-WebSocket-Protocol: ' + this._protocols.join(', ')); 59 | 60 | return new Buffer(headers.concat('','').join('\r\n'), 'utf8'); 61 | }; 62 | 63 | Handshake.prototype.parse = function(data) { 64 | var consumed = this._parser.execute(data, 0, data.length), 65 | offset = (this._nodeVersion < 6) ? 1 : 0; 66 | 67 | return (consumed === data.length) ? [] : data.slice(consumed + offset); 68 | }; 69 | 70 | Handshake.prototype.isComplete = function() { 71 | return this._complete; 72 | }; 73 | 74 | Handshake.prototype.isValid = function() { 75 | if (this._status !== 101) return false; 76 | 77 | var upgrade = this._headers.Upgrade, 78 | connection = this._headers.Connection, 79 | protocol = this._headers['Sec-WebSocket-Protocol']; 80 | 81 | this.protocol = this._protocols && this._protocols.indexOf(protocol) >= 0 82 | ? protocol 83 | : null; 84 | 85 | return upgrade && /^websocket$/i.test(upgrade) && 86 | connection && connection.split(/\s*,\s*/).indexOf('Upgrade') >= 0 && 87 | ((!this._protocols && !protocol) || this.protocol) && 88 | this._headers['Sec-WebSocket-Accept'] === this._accept; 89 | }; 90 | 91 | module.exports = Handshake; 92 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/lib/faye/websocket/hybi_parser/stream_reader.js: -------------------------------------------------------------------------------- 1 | var StreamReader = function() { 2 | this._queue = []; 3 | this._cursor = 0; 4 | }; 5 | 6 | StreamReader.prototype.read = function(bytes) { 7 | return this._readBuffer(bytes); 8 | }; 9 | 10 | StreamReader.prototype.put = function(buffer) { 11 | if (!buffer || buffer.length === 0) return; 12 | if (!buffer.copy) buffer = new Buffer(buffer); 13 | this._queue.push(buffer); 14 | }; 15 | 16 | StreamReader.prototype._readBuffer = function(length) { 17 | var buffer = new Buffer(length), 18 | queue = this._queue, 19 | remain = length, 20 | n = queue.length, 21 | i = 0, 22 | chunk, offset, size; 23 | 24 | if (remain === 0) return buffer; 25 | 26 | while (remain > 0 && i < n) { 27 | chunk = queue[i]; 28 | offset = (i === 0) ? this._cursor : 0; 29 | size = Math.min(remain, chunk.length - offset); 30 | chunk.copy(buffer, length - remain, offset, offset + size); 31 | remain -= size; 32 | i += 1; 33 | } 34 | 35 | if (remain > 0) return null; 36 | 37 | queue.splice(0, i-1); 38 | this._cursor = (i === 1 ? this._cursor : 0) + size; 39 | 40 | return buffer; 41 | }; 42 | 43 | module.exports = StreamReader; 44 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "faye-websocket", 3 | "description": "Standards-compliant WebSocket server and client", 4 | "homepage": "http://github.com/faye/faye-websocket-node", 5 | "author": { 6 | "name": "James Coglan", 7 | "email": "jcoglan@gmail.com", 8 | "url": "http://jcoglan.com/" 9 | }, 10 | "keywords": [ 11 | "websocket", 12 | "eventsource" 13 | ], 14 | "version": "0.4.0", 15 | "engines": { 16 | "node": ">=0.4.0" 17 | }, 18 | "main": "./lib/faye/websocket", 19 | "devDependencies": { 20 | "jsclass": "" 21 | }, 22 | "scripts": { 23 | "test": "node spec/runner.js" 24 | }, 25 | "bugs": { 26 | "name": "http://github.com/faye/faye-websocket-node/issues" 27 | }, 28 | "licenses": [ 29 | { 30 | "type": "MIT", 31 | "url": "http://www.opensource.org/licenses/mit-license.php" 32 | } 33 | ], 34 | "repositories": [ 35 | { 36 | "type": "git", 37 | "url": "git://github.com/faye/faye-websocket-node.git" 38 | } 39 | ], 40 | "_npmUser": { 41 | "name": "maxogden", 42 | "email": "max@maxogden.com" 43 | }, 44 | "_id": "faye-websocket@0.4.0", 45 | "dependencies": {}, 46 | "optionalDependencies": {}, 47 | "_engineSupported": true, 48 | "_npmVersion": "1.1.21", 49 | "_nodeVersion": "v0.6.18", 50 | "_defaultsLoaded": true, 51 | "dist": { 52 | "shasum": "3b572d0f393bf8c8ec8dec06a4bfbf0078f36f0a" 53 | }, 54 | "_from": "faye-websocket@0.4.0" 55 | } 56 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/spec/faye/websocket/draft75parser_spec.js: -------------------------------------------------------------------------------- 1 | var Draft75Parser = require('../../../lib/faye/websocket/draft75_parser') 2 | 3 | JS.ENV.Draft75ParserSpec = JS.Test.describe("Draft75Parser", function() { with(this) { 4 | before(function() { with(this) { 5 | this.webSocket = {dispatchEvent: function() {}} 6 | this.parser = new Draft75Parser(webSocket) 7 | }}) 8 | 9 | describe("parse", function() { with(this) { 10 | sharedBehavior("draft-75 parser", function() { with(this) { 11 | it("parses text frames", function() { with(this) { 12 | expect(webSocket, "receive").given("Hello") 13 | parser.parse([0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]) 14 | }}) 15 | 16 | it("parses multiple frames from the same packet", function() { with(this) { 17 | expect(webSocket, "receive").given("Hello").exactly(2) 18 | parser.parse([0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]) 19 | }}) 20 | 21 | it("parses text frames beginning 0x00-0x7F", function() { with(this) { 22 | expect(webSocket, "receive").given("Hello") 23 | parser.parse([0x66, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]) 24 | }}) 25 | 26 | it("ignores frames with a length header", function() { with(this) { 27 | expect(webSocket, "receive").exactly(0) 28 | parser.parse([0x80, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]) 29 | }}) 30 | 31 | it("parses text following an ignored block", function() { with(this) { 32 | expect(webSocket, "receive").given("Hello") 33 | parser.parse([0x80, 0x02, 0x48, 0x65, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff]) 34 | }}) 35 | 36 | it("parses multibyte text frames", function() { with(this) { 37 | expect(webSocket, "receive").given("Apple = ") 38 | parser.parse([0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]) 39 | }}) 40 | 41 | it("parses frames received in several packets", function() { with(this) { 42 | expect(webSocket, "receive").given("Apple = ") 43 | parser.parse([0x00, 0x41, 0x70, 0x70, 0x6c, 0x65]) 44 | parser.parse([0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff]) 45 | }}) 46 | 47 | it("parses fragmented frames", function() { with(this) { 48 | expect(webSocket, "receive").given("Hello") 49 | parser.parse([0x00, 0x48, 0x65, 0x6c]) 50 | parser.parse([0x6c, 0x6f, 0xff]) 51 | }}) 52 | }}) 53 | 54 | behavesLike("draft-75 parser") 55 | 56 | it("does not close the socket if a 76 close frame is received", function() { with(this) { 57 | expect(webSocket, "close").exactly(0) 58 | expect(webSocket, "receive").given("") 59 | parser.parse([0xFF, 0x00]) 60 | }}) 61 | }}) 62 | 63 | describe("frame", function() { with(this) { 64 | it("returns the given string formatted as a WebSocket frame", function() { with(this) { 65 | assertBufferEqual( [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff], parser.frame("Hello") ) 66 | }}) 67 | 68 | it("encodes multibyte characters correctly", function() { with(this) { 69 | assertBufferEqual( [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff], parser.frame("Apple = ") ) 70 | }}) 71 | }}) 72 | }}) 73 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/spec/faye/websocket/draft76parser_spec.js: -------------------------------------------------------------------------------- 1 | var Draft76Parser = require('../../../lib/faye/websocket/draft76_parser') 2 | 3 | JS.ENV.Draft76ParserSpec = JS.Test.describe("Draft76Parser", function() { with(this) { 4 | before(function() { with(this) { 5 | this.webSocket = {dispatchEvent: function() {}} 6 | this.parser = new Draft76Parser(webSocket) 7 | parser._handshakeComplete = true 8 | }}) 9 | 10 | describe("parse", function() { with(this) { 11 | behavesLike("draft-75 parser") 12 | 13 | it("closes the socket if a close frame is received", function() { with(this) { 14 | expect(webSocket, "close") 15 | parser.parse([0xFF, 0x00]) 16 | }}) 17 | }}) 18 | 19 | describe("frame", function() { with(this) { 20 | it("returns the given string formatted as a WebSocket frame", function() { with(this) { 21 | assertBufferEqual( [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff], parser.frame("Hello") ) 22 | }}) 23 | 24 | it("encodes multibyte characters correctly", function() { with(this) { 25 | assertBufferEqual( [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff], parser.frame("Apple = ") ) 26 | }}) 27 | }}) 28 | }}) 29 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/spec/runner.js: -------------------------------------------------------------------------------- 1 | require('jsclass') 2 | 3 | var WebSocket = require('../lib/faye/websocket'), 4 | fs = require('fs'), 5 | http = require('http'), 6 | https = require('https') 7 | 8 | 9 | JS.ENV.EchoServer = function() {} 10 | EchoServer.prototype.listen = function(port, ssl) { 11 | var server = ssl 12 | ? https.createServer({ 13 | key: fs.readFileSync(__dirname + '/server.key'), 14 | cert: fs.readFileSync(__dirname + '/server.crt') 15 | }) 16 | : http.createServer() 17 | 18 | server.addListener('upgrade', function(request, socket, head) { 19 | var ws = new WebSocket(request, socket, head, ["echo"]) 20 | ws.onmessage = function(event) { 21 | ws.send(event.data) 22 | } 23 | }) 24 | this._httpServer = server 25 | server.listen(port) 26 | } 27 | EchoServer.prototype.stop = function(callback, scope) { 28 | this._httpServer.addListener('close', function() { 29 | if (callback) callback.call(scope); 30 | }); 31 | this._httpServer.close(); 32 | } 33 | 34 | 35 | JS.Packages(function() { with(this) { 36 | autoload(/.*Spec/, {from: 'spec/faye/websocket'}) 37 | }}) 38 | 39 | 40 | JS.require('JS.Test', function() { 41 | JS.Test.Unit.Assertions.define("assertBufferEqual", function(array, buffer) { 42 | this.assertEqual(array.length, buffer.length); 43 | var ary = [], n = buffer.length; 44 | while (n--) ary[n] = buffer[n]; 45 | this.assertEqual(array, ary); 46 | }) 47 | 48 | JS.require( 'ClientSpec', 49 | 'Draft75ParserSpec', 50 | 'Draft76ParserSpec', 51 | 'HybiParserSpec', 52 | JS.Test.method('autorun')) 53 | }) 54 | 55 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/spec/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICZTCCAc4CCQDxyrJZrFA0vjANBgkqhkiG9w0BAQUFADB3MQswCQYDVQQGEwJV 3 | SzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTALBgNVBAoTBEZh 4 | eWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJARYRamNvZ2xh 5 | bkBnbWFpbC5jb20wHhcNMTEwODMwMTIzOTM2WhcNMTIwODI5MTIzOTM2WjB3MQsw 6 | CQYDVQQGEwJVSzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTAL 7 | BgNVBAoTBEZheWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJ 8 | ARYRamNvZ2xhbkBnbWFpbC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB 9 | AMDjU5fAK7fvUCZIYHcGXDZD/m9bY+B/UcwGcowk0hMQGYNlLKrpiK7xXBmZpDb6 10 | r8n+7L/epBeSumbRIm4TDzeNHhuQGYLIeGQy7JNLoPBr6GxubjuJhKOOBnCqcupR 11 | CLGG7Zw5oL4UvtZVH6kL9XnjyokQQbxxeoV9DqtqOaHHAgMBAAEwDQYJKoZIhvcN 12 | AQEFBQADgYEAvQjSpzE1ahaeH1CmbLwckTxvWMZfxcZOrxTruK1po3cNnDOjGqFQ 13 | KEkNj3K5WfwTBD4QgUdYDykhDX2m6HaMz4JEbgrwQv8M8FiswIA3dyGsbOifOk8H 14 | r3GPNKMzm4o6vrn6RGOpt9q6bsWUBUHfNpP93uU2C9QEwDua3cFjDA0= 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/faye-websocket/spec/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXAIBAAKBgQDA41OXwCu371AmSGB3Blw2Q/5vW2Pgf1HMBnKMJNITEBmDZSyq 3 | 6Yiu8VwZmaQ2+q/J/uy/3qQXkrpm0SJuEw83jR4bkBmCyHhkMuyTS6Dwa+hsbm47 4 | iYSjjgZwqnLqUQixhu2cOaC+FL7WVR+pC/V548qJEEG8cXqFfQ6rajmhxwIDAQAB 5 | AoGABlk1DiCQD8y7mZb2PdSiwlJ4lFewsNnf6lQn/v7TPzdfb5ir4LAxBHkDLACH 6 | jBuyH3bZefMs+W2l3u5xMKhF7uJqYcUlJdH2UwRfNG54Hn4SGAjQOK3ONer99sUf 7 | USlsWSX1HjAAFMCBwUfKxMZA3VNQfYKTPdm0jSVf85kHO1ECQQD3s6ksm3QpfD0L 8 | eG9EoDrqmwnEfpKoWPpz1O0i5tY9VcmhmLwS5Zpd7lB1qjTqzZk4RygU73T/BseJ 9 | azehIHK5AkEAx1mSXt+ec8RfzVi/io6oqi2vOcACXRbOG4NQmqUWPnumdwsJjsjR 10 | RzEoDFC2lu6448p9sgEq+CkbmgVeiyp4fwJAQnmgySve/NMuvslPcyddKGD7OhSN 11 | 30ghzrwx98/jZwqC1i9bKeccimDOjwVitjD/Ea9m/ldVGqwDGMoBX+iJYQJAEIOO 12 | CYfyw1pQKV2huGOq+zX/nwQV7go2lrbhFX55gkGR/6iNaSOfmosq6yJAje5GqLAc 13 | i4NnQNl+7NpnA5ZIFwJBAI1+OsZyjbRI99pYkTdOpa5IPlIb3j3JbSfjAWHLxlRY 14 | 0HLvN3Q1mE9kbB+uKH6syF/S7nALgsLgq7eHYvIaE/A= 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Robert Kieffer 2 | 3 | Dual licensed under the [MIT](http://en.wikipedia.org/wiki/MIT_License) and [GPL](http://en.wikipedia.org/wiki/GNU_General_Public_License) licenses. 4 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/benchmark/README.md: -------------------------------------------------------------------------------- 1 | # node-uuid Benchmarks 2 | 3 | ### Results 4 | 5 | To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark 6 | 7 | ### Run them yourself 8 | 9 | node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`. 10 | 11 | To prepare and run the benchmark issue; 12 | 13 | ``` 14 | npm install uuid uuid-js 15 | node benchmark/benchmark.js 16 | ``` 17 | 18 | You'll see an output like this one: 19 | 20 | ``` 21 | # v4 22 | nodeuuid.v4(): 854700 uuids/second 23 | nodeuuid.v4('binary'): 788643 uuids/second 24 | nodeuuid.v4('binary', buffer): 1336898 uuids/second 25 | uuid(): 479386 uuids/second 26 | uuid('binary'): 582072 uuids/second 27 | uuidjs.create(4): 312304 uuids/second 28 | 29 | # v1 30 | nodeuuid.v1(): 938086 uuids/second 31 | nodeuuid.v1('binary'): 683060 uuids/second 32 | nodeuuid.v1('binary', buffer): 1644736 uuids/second 33 | uuidjs.create(1): 190621 uuids/second 34 | ``` 35 | 36 | * The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library. 37 | * The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK. 38 | 39 | If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file: 40 | 41 | ``` 42 | for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done; 43 | ``` 44 | 45 | If you're interested in how performance varies between different node versions, you can issue the above command multiple times. 46 | 47 | You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot: 48 | 49 | ``` 50 | (cd benchmark/ && ./bench.sh) 51 | ``` 52 | 53 | This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then. 54 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/benchmark/bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # for a given node version run: 4 | # for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done; 5 | 6 | PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte') 7 | FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es) 8 | INDICES=(2 3 2 3 2 2 2 2 2) 9 | VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " ) 10 | TMPJOIN="tmp_join" 11 | OUTPUT="bench_results.txt" 12 | 13 | for I in ${!FILES[*]}; do 14 | F=${FILES[$I]} 15 | P=${PATTERNS[$I]} 16 | INDEX=${INDICES[$I]} 17 | echo "version $F" > $F 18 | for V in $VERSIONS; do 19 | (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F 20 | done 21 | if [ $I == 0 ]; then 22 | cat $F > $TMPJOIN 23 | else 24 | join $TMPJOIN $F > $OUTPUT 25 | cp $OUTPUT $TMPJOIN 26 | fi 27 | rm $F 28 | done 29 | 30 | rm $TMPJOIN 31 | 32 | gnuplot bench.gnu 33 | convert -density 200 -resize 800x560 -flatten bench.eps bench.png 34 | rm bench.eps 35 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/benchmark/benchmark-native.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test performance of native C UUID generation 3 | 4 | To Compile: cc -luuid benchmark-native.c -o benchmark-native 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() { 13 | uuid_t myid; 14 | char buf[36+1]; 15 | int i; 16 | struct timeval t; 17 | double start, finish; 18 | 19 | gettimeofday(&t, NULL); 20 | start = t.tv_sec + t.tv_usec/1e6; 21 | 22 | int n = 2e5; 23 | for (i = 0; i < n; i++) { 24 | uuid_generate(myid); 25 | uuid_unparse(myid, buf); 26 | } 27 | 28 | gettimeofday(&t, NULL); 29 | finish = t.tv_sec + t.tv_usec/1e6; 30 | double dur = finish - start; 31 | 32 | printf("%d uuids/sec", (int)(n/dur)); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/benchmark/benchmark.js: -------------------------------------------------------------------------------- 1 | try { 2 | var nodeuuid = require('../uuid'); 3 | } catch (e) { 4 | console.error('node-uuid require failed - skipping tests'); 5 | } 6 | 7 | try { 8 | var uuid = require('uuid'); 9 | } catch (e) { 10 | console.error('uuid require failed - skipping tests'); 11 | } 12 | 13 | try { 14 | var uuidjs = require('uuid-js'); 15 | } catch (e) { 16 | console.error('uuid-js require failed - skipping tests'); 17 | } 18 | 19 | var N = 5e5; 20 | 21 | function rate(msg, t) { 22 | console.log(msg + ': ' + 23 | (N / (Date.now() - t) * 1e3 | 0) + 24 | ' uuids/second'); 25 | } 26 | 27 | console.log('# v4'); 28 | 29 | // node-uuid - string form 30 | if (nodeuuid) { 31 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4(); 32 | rate('nodeuuid.v4() - using node.js crypto RNG', t); 33 | 34 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG}); 35 | rate('nodeuuid.v4() - using Math.random() RNG', t); 36 | 37 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary'); 38 | rate('nodeuuid.v4(\'binary\')', t); 39 | 40 | var buffer = new nodeuuid.BufferClass(16); 41 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer); 42 | rate('nodeuuid.v4(\'binary\', buffer)', t); 43 | } 44 | 45 | // libuuid - string form 46 | if (uuid) { 47 | for (var i = 0, t = Date.now(); i < N; i++) uuid(); 48 | rate('uuid()', t); 49 | 50 | for (var i = 0, t = Date.now(); i < N; i++) uuid('binary'); 51 | rate('uuid(\'binary\')', t); 52 | } 53 | 54 | // uuid-js - string form 55 | if (uuidjs) { 56 | for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4); 57 | rate('uuidjs.create(4)', t); 58 | } 59 | 60 | // 140byte.es 61 | for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)}); 62 | rate('140byte.es_v4', t); 63 | 64 | console.log(''); 65 | console.log('# v1'); 66 | 67 | // node-uuid - v1 string form 68 | if (nodeuuid) { 69 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1(); 70 | rate('nodeuuid.v1()', t); 71 | 72 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary'); 73 | rate('nodeuuid.v1(\'binary\')', t); 74 | 75 | var buffer = new nodeuuid.BufferClass(16); 76 | for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer); 77 | rate('nodeuuid.v1(\'binary\', buffer)', t); 78 | } 79 | 80 | // uuid-js - v1 string form 81 | if (uuidjs) { 82 | for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1); 83 | rate('uuidjs.create(1)', t); 84 | } 85 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-uuid", 3 | "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", 4 | "url": "http://github.com/broofa/node-uuid", 5 | "keywords": [ 6 | "uuid", 7 | "guid", 8 | "rfc4122" 9 | ], 10 | "author": { 11 | "name": "Robert Kieffer", 12 | "email": "robert@broofa.com" 13 | }, 14 | "contributors": [ 15 | { 16 | "name": "Christoph Tavan", 17 | "email": "dev@tavan.de" 18 | } 19 | ], 20 | "lib": ".", 21 | "main": "./uuid.js", 22 | "repository": { 23 | "type": "git", 24 | "url": "git://github.com/broofa/node-uuid.git" 25 | }, 26 | "version": "1.3.3", 27 | "_npmUser": { 28 | "name": "maxogden", 29 | "email": "max@maxogden.com" 30 | }, 31 | "_id": "node-uuid@1.3.3", 32 | "dependencies": {}, 33 | "devDependencies": {}, 34 | "optionalDependencies": {}, 35 | "engines": { 36 | "node": "*" 37 | }, 38 | "_engineSupported": true, 39 | "_npmVersion": "1.1.21", 40 | "_nodeVersion": "v0.6.18", 41 | "_defaultsLoaded": true, 42 | "dist": { 43 | "shasum": "a271d9a233e2606a9c785196e122f76f28b12967" 44 | }, 45 | "_from": "node-uuid@1.3.3" 46 | } 47 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/test/compare_v1.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'), 2 | nodeuuid = require('../uuid'), 3 | uuidjs = require('uuid-js'), 4 | libuuid = require('uuid').generate, 5 | util = require('util'), 6 | exec = require('child_process').exec, 7 | os = require('os'); 8 | 9 | // On Mac Os X / macports there's only the ossp-uuid package that provides uuid 10 | // On Linux there's uuid-runtime which provides uuidgen 11 | var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t'; 12 | 13 | function compare(ids) { 14 | console.log(ids); 15 | for (var i = 0; i < ids.length; i++) { 16 | var id = ids[i].split('-'); 17 | id = [id[2], id[1], id[0]].join(''); 18 | ids[i] = id; 19 | } 20 | var sorted = ([].concat(ids)).sort(); 21 | 22 | if (sorted.toString() !== ids.toString()) { 23 | console.log('Warning: sorted !== ids'); 24 | } else { 25 | console.log('everything in order!'); 26 | } 27 | } 28 | 29 | // Test time order of v1 uuids 30 | var ids = []; 31 | while (ids.length < 10e3) ids.push(nodeuuid.v1()); 32 | 33 | var max = 10; 34 | console.log('node-uuid:'); 35 | ids = []; 36 | for (var i = 0; i < max; i++) ids.push(nodeuuid.v1()); 37 | compare(ids); 38 | 39 | console.log(''); 40 | console.log('uuidjs:'); 41 | ids = []; 42 | for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString()); 43 | compare(ids); 44 | 45 | console.log(''); 46 | console.log('libuuid:'); 47 | ids = []; 48 | var count = 0; 49 | var last = function() { 50 | compare(ids); 51 | } 52 | var cb = function(err, stdout, stderr) { 53 | ids.push(stdout.substring(0, stdout.length-1)); 54 | count++; 55 | if (count < max) { 56 | return next(); 57 | } 58 | last(); 59 | }; 60 | var next = function() { 61 | exec(uuidCmd, cb); 62 | }; 63 | next(); 64 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/node-uuid/test/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/.npmignore: -------------------------------------------------------------------------------- 1 | .lock-wscript 2 | /nbproject 3 | /build -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Aleksander Williams 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/Makefile: -------------------------------------------------------------------------------- 1 | WAF=node-waf 2 | 3 | build: 4 | @$(WAF) configure build 5 | 6 | clean: 7 | @$(WAF) clean 8 | 9 | .PHONY: build clean -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/README.md: -------------------------------------------------------------------------------- 1 | rbytes 2 | ====== 3 | 4 | > Generates cryptographically secure random byte sequences 5 | 6 | rbytes generates cryptographically secure random byte sequences using native bindings to OpenSSL's [pseudo random number generator](http://www.openssl.org/docs/crypto/rand.html). Use rbytes to generate session keys, UUIDs or anything else that requires fast generation of blocks of random data. 7 | 8 | Synopsis 9 | -------- 10 | 11 | Create a buffer holding 16 random bytes: 12 | 13 | var rbytes = require('rbytes'); 14 | 15 | var rbuff = rbytes.randomBytes(16); 16 | // 17 | 18 | rbytes adds two convenience methods to Node's Buffer class for easy conversion between Buffers and hex strings: 19 | 20 | rbuff.toHex(); 21 | // '695d5df642041b86f2775d2b4f0f7226' 22 | 23 | var buff = Buffer(1); 24 | buff.writeHex('f'); 25 | // 26 | 27 | buff.writeHex('g'); 28 | // TypeError: Invalid hex string 29 | 30 | Installation 31 | ------------ 32 | 33 | $ npm install rbytes 34 | 35 | rbytes requires node version 0.3.0 or higher. 36 | 37 | Notes 38 | ----- 39 | 40 | rbytes binds to OpenSSL's [RAND_bytes](http://www.openssl.org/docs/crypto/RAND_bytes.html) function, which generates cryptographically strong pseudorandom bytes. This function does not block, however it will throw an error if there isn't enough random seed data on your system. Support is planned for RAND_pseudo_bytes, which are guaranteed to be available at the cost of being (potentially) less secure. 41 | 42 | Simple random number generation (like Math.rand()) is planned for a future version. -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/.wafpickle-7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/max-mapper/domnode/64f035ed2dc804b6d8d9ae31991dd39fec11908d/videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/.wafpickle-7 -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/Release/binding.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/max-mapper/domnode/64f035ed2dc804b6d8d9ae31991dd39fec11908d/videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/Release/binding.node -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/Release/src/binding_1.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/max-mapper/domnode/64f035ed2dc804b6d8d9ae31991dd39fec11908d/videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/Release/src/binding_1.o -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/c4che/Release.cache.py: -------------------------------------------------------------------------------- 1 | AR = '/usr/bin/ar' 2 | ARFLAGS = 'rcs' 3 | CCFLAGS = ['-g'] 4 | CCFLAGS_MACBUNDLE = ['-fPIC'] 5 | CCFLAGS_NODE = ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] 6 | CC_VERSION = ('4', '2', '1') 7 | COMPILER_CXX = 'g++' 8 | CPP = '/usr/bin/cpp' 9 | CPPFLAGS_NODE = ['-D_GNU_SOURCE'] 10 | CPPPATH_NODE = '/usr/local/include/node' 11 | CPPPATH_ST = '-I%s' 12 | CXX = ['/usr/bin/g++'] 13 | CXXDEFINES_ST = '-D%s' 14 | CXXFLAGS = ['-g'] 15 | CXXFLAGS_DEBUG = ['-g'] 16 | CXXFLAGS_NODE = ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] 17 | CXXFLAGS_RELEASE = ['-O2'] 18 | CXXLNK_SRC_F = '' 19 | CXXLNK_TGT_F = ['-o', ''] 20 | CXX_NAME = 'gcc' 21 | CXX_SRC_F = '' 22 | CXX_TGT_F = ['-c', '-o', ''] 23 | DEST_CPU = 'x86_64' 24 | DEST_OS = 'darwin' 25 | FULLSTATIC_MARKER = '-static' 26 | LIBDIR = '/usr/local/lib/node_modules' 27 | LIBPATH_NODE = '/usr/local/lib' 28 | LIBPATH_ST = '-L%s' 29 | LIB_ST = '-l%s' 30 | LINKFLAGS_MACBUNDLE = ['-bundle', '-undefined', 'dynamic_lookup'] 31 | LINK_CXX = ['/usr/bin/g++'] 32 | NODE_PATH = '/usr/local/lib/node_modules' 33 | PREFIX = '/usr/local' 34 | PREFIX_NODE = '/usr/local' 35 | RANLIB = '/usr/bin/ranlib' 36 | RPATH_ST = '-Wl,-rpath,%s' 37 | SHLIB_MARKER = '' 38 | SONAME_ST = '' 39 | STATICLIBPATH_ST = '-L%s' 40 | STATICLIB_MARKER = '' 41 | STATICLIB_ST = '-l%s' 42 | macbundle_PATTERN = '%s.bundle' 43 | program_PATTERN = '%s' 44 | shlib_CXXFLAGS = ['-fPIC', '-compatibility_version', '1', '-current_version', '1'] 45 | shlib_LINKFLAGS = ['-dynamiclib'] 46 | shlib_PATTERN = 'lib%s.dylib' 47 | staticlib_LINKFLAGS = [] 48 | staticlib_PATTERN = 'lib%s.a' 49 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/c4che/build.config.py: -------------------------------------------------------------------------------- 1 | version = 0x105016 2 | tools = [{'tool': 'ar', 'tooldir': None, 'funs': None}, {'tool': 'cxx', 'tooldir': None, 'funs': None}, {'tool': 'gxx', 'tooldir': None, 'funs': None}, {'tool': 'compiler_cxx', 'tooldir': None, 'funs': None}, {'tool': 'osx', 'tooldir': None, 'funs': None}, {'tool': 'node_addon', 'tooldir': None, 'funs': None}] 3 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/build/config.log: -------------------------------------------------------------------------------- 1 | # project noname (0.0.1) configured on Sat Jun 23 10:21:29 2012 by 2 | # waf 1.5.16 (abi 7, python 20701f0 on darwin) 3 | # using /usr/local/bin/node-waf configure build 4 | # 5 | 6 | ---------------------------------------- 7 | Checking for program g++ or c++ 8 | find program=['g++', 'c++'] paths=[] var='CXX' 9 | -> '/usr/bin/g++' 10 | 11 | ---------------------------------------- 12 | Checking for program cpp 13 | find program=['cpp'] paths=[] var='CPP' 14 | -> '/usr/bin/cpp' 15 | 16 | ---------------------------------------- 17 | Checking for program ar 18 | find program=['ar'] paths=[] var='AR' 19 | -> '/usr/bin/ar' 20 | 21 | ---------------------------------------- 22 | Checking for program ranlib 23 | find program=['ranlib'] paths=[] var='RANLIB' 24 | -> '/usr/bin/ranlib' 25 | 26 | ---------------------------------------- 27 | Checking for g++ 28 | ok 29 | 30 | ---------------------------------------- 31 | Checking for node path 32 | ok /usr/local/lib/node_modules 33 | 34 | ---------------------------------------- 35 | Checking for node prefix 36 | ok /usr/local 37 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/index.js: -------------------------------------------------------------------------------- 1 | var binding = require('./build/default/binding'); 2 | 3 | Buffer.prototype.toHex = function() { 4 | return binding.bufToHex(this); 5 | }; 6 | 7 | Buffer.prototype.writeHex = function(hex) { 8 | return binding.hexToBuf(hex, this); 9 | }; 10 | 11 | exports.randomBytes = function(len) { 12 | var b = new Buffer(len); 13 | binding.randomBytes(b); 14 | return b; 15 | }; -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rbytes", 3 | "version": "0.0.2", 4 | "description": "Generates cryptographically secure random byte sequences", 5 | "author": { 6 | "name": "Aleksander Williams" 7 | }, 8 | "contributors": [], 9 | "engines": { 10 | "node": ">=0.3.0" 11 | }, 12 | "url": "http://akdubya.github.com/rbytes/", 13 | "keywords": [ 14 | "random", 15 | "crypto" 16 | ], 17 | "main": "index", 18 | "scripts": { 19 | "install": "node-waf configure build" 20 | }, 21 | "_npmUser": { 22 | "name": "maxogden", 23 | "email": "max@maxogden.com" 24 | }, 25 | "_id": "rbytes@0.0.2", 26 | "dependencies": {}, 27 | "devDependencies": {}, 28 | "optionalDependencies": {}, 29 | "_engineSupported": true, 30 | "_npmVersion": "1.1.21", 31 | "_nodeVersion": "v0.6.18", 32 | "_defaultsLoaded": true, 33 | "dist": { 34 | "shasum": "f788165ff5dad52f3a8b2004a9939b0c53abd75d" 35 | }, 36 | "_from": "rbytes@0.0.2" 37 | } 38 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/test.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var log = console.log; 3 | var rbytes = require('./index'); 4 | var buf; 5 | var octets = [0xa8, 0x75, 0xfe, 0xae, 0xc6, 0x7f, 0x00, 0x00, 0xa8, 0x75]; 6 | 7 | log("random bytes"); 8 | buf = rbytes.randomBytes(12); 9 | assert.ok(Buffer.isBuffer(buf)); 10 | assert.equal(buf.length, 12); 11 | 12 | log("buffer to hex"); 13 | buf = Buffer(octets); 14 | assert.equal(buf.toHex(), "a875feaec67f0000a875"); 15 | 16 | log("write hex to buffer"); 17 | buf = Buffer(10); 18 | assert.equal(buf.writeHex("a875feaec67f0000a875"), 10); 19 | assert.equal(buf.length, 10); 20 | for (var i=0; i<10; i++) { 21 | assert.equal(buf[i], octets[i]); 22 | } 23 | 24 | log("add leading 0"); 25 | buf = Buffer(1) 26 | assert.equal(buf.writeHex("f"), 1); 27 | assert.equal(buf.toHex(), "0f"); 28 | 29 | log("too small"); 30 | buf = Buffer(1); 31 | assert.throws(function() { buf.writeHex("ffff") }, 32 | Error, "Buffer too small"); 33 | 34 | buf = Buffer(10); 35 | assert.throws(function() { buf.writeHex("a875feaec67f0000a8751") }, 36 | Error, "Buffer too small"); 37 | 38 | log("invalid hex"); 39 | buf = Buffer(10); 40 | assert.throws(function() { buf.writeHex("gfhf") }, 41 | TypeError, "Invalid hex string"); 42 | 43 | buf = Buffer(1); 44 | assert.throws(function() { buf.writeHex("g") }, 45 | TypeError, "Invalid hex string"); -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/node_modules/rbytes/wscript: -------------------------------------------------------------------------------- 1 | import Options 2 | import sys 3 | 4 | srcdir = "." 5 | blddir = "build" 6 | VERSION = "0.0.1" 7 | 8 | def set_options(opt): 9 | opt.tool_options("compiler_cxx") 10 | 11 | def configure(conf): 12 | conf.check_tool("compiler_cxx") 13 | conf.check_tool("node_addon") 14 | 15 | def build(bld): 16 | obj = bld.new_task_gen("cxx", "shlib", "node_addon") 17 | obj.target = "binding" 18 | obj.source = "./src/binding.cc" -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/node_modules/sockjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockjs", 3 | "author": { 4 | "name": "Marek Majkowski" 5 | }, 6 | "version": "0.3.1", 7 | "description": "SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.", 8 | "keywords": [ 9 | "websockets", 10 | "websocket" 11 | ], 12 | "homepage": "https://github.com/sockjs/sockjs-node", 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/sockjs/sockjs-node.git" 16 | }, 17 | "dependencies": { 18 | "node-uuid": "1.3.3", 19 | "faye-websocket": "0.4.0", 20 | "rbytes": "0.0.2" 21 | }, 22 | "optionalDependencies": { 23 | "rbytes": "0.0.2" 24 | }, 25 | "devDependencies": { 26 | "coffee-script": "1.2.x" 27 | }, 28 | "main": "index", 29 | "_npmUser": { 30 | "name": "maxogden", 31 | "email": "max@maxogden.com" 32 | }, 33 | "_id": "sockjs@0.3.1", 34 | "engines": { 35 | "node": "*" 36 | }, 37 | "_engineSupported": true, 38 | "_npmVersion": "1.1.21", 39 | "_nodeVersion": "v0.6.18", 40 | "_defaultsLoaded": true, 41 | "dist": { 42 | "shasum": "d7e9a4c21e1fe44da82eee4ea6c49ead855ab133" 43 | }, 44 | "_from": "sockjs@~0.3.1" 45 | } 46 | -------------------------------------------------------------------------------- /videostreaming-demo/node_modules/shoe/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shoe", 3 | "version": "0.0.0", 4 | "description": "streaming sockjs for node and the browser", 5 | "main": "index.js", 6 | "browserify": "browser.js", 7 | "directories": { 8 | "example": "example" 9 | }, 10 | "dependencies": { 11 | "sockjs": "~0.3.1", 12 | "sockjs-client": "git://github.com/substack/sockjs-client.git#browserify-npm" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git://github.com/substack/shoe.git" 17 | }, 18 | "homepage": "https://github.com/substack/shoe", 19 | "keywords": [ 20 | "websocket", 21 | "stream", 22 | "sock", 23 | "browserify" 24 | ], 25 | "author": { 26 | "name": "James Halliday", 27 | "email": "mail@substack.net", 28 | "url": "http://substack.net" 29 | }, 30 | "license": "MIT", 31 | "engine": { 32 | "node": ">=0.6" 33 | }, 34 | "_npmUser": { 35 | "name": "maxogden", 36 | "email": "max@maxogden.com" 37 | }, 38 | "_id": "shoe@0.0.0", 39 | "devDependencies": {}, 40 | "optionalDependencies": {}, 41 | "engines": { 42 | "node": "*" 43 | }, 44 | "_engineSupported": true, 45 | "_npmVersion": "1.1.21", 46 | "_nodeVersion": "v0.6.18", 47 | "_defaultsLoaded": true, 48 | "dist": { 49 | "shasum": "27ef38eacc35cbfbb0eeaab8f512ef04c73d76b3" 50 | }, 51 | "_from": "shoe" 52 | } 53 | -------------------------------------------------------------------------------- /videostreaming-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.1", 3 | "name": "domnode-videochat" 4 | } -------------------------------------------------------------------------------- /videostreaming-demo/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var ecstatic = require('ecstatic')(__dirname); 3 | var shoe = require('shoe'); 4 | 5 | var server = http.createServer(ecstatic); 6 | server.listen(8000); 7 | 8 | var clients = [] 9 | 10 | var broadcast = shoe(function (stream) { 11 | stream.on('data', function(data) { 12 | clients.forEach(function(client) { 13 | client.write(data) 14 | }) 15 | }) 16 | stream.on('end', function() { 17 | clients.forEach(function(client) { 18 | client.end() 19 | }) 20 | }) 21 | }); 22 | broadcast.install(server, '/broadcast'); 23 | 24 | var view = shoe(function (stream) { 25 | clients.push(stream) 26 | }); 27 | view.install(server, '/view'); 28 | 29 | console.log('open localhost:8000 to view and localhost:8000/broadcast.html to broadcast (from a webrtc enabled browser like Canary or Firefox)') -------------------------------------------------------------------------------- /videostreaming-demo/view.js: -------------------------------------------------------------------------------- 1 | var shoe = require('shoe') 2 | var img = document.querySelector('img') 3 | var view = shoe('/view') 4 | view.on('data', function(data) { 5 | img.src = data 6 | }) 7 | --------------------------------------------------------------------------------