aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlan K <github@ack.modeswitch.org>2014-03-17 19:28:04 -0400
committerAlan K <github@ack.modeswitch.org>2014-03-17 19:28:04 -0400
commitcf5307c029a9f5e502ddfb1d1949ab4d2a5bd4e5 (patch)
tree964f6e38b444de7efb31940e79e659fa94bc9378 /tests
parentb1f141debf8800c453a5a992fa04862e29f1cdc2 (diff)
Cleaned up required files (some things aren't needed for this test); Run `npm install` as part of test.
Diffstat (limited to 'tests')
-rw-r--r--tests/sockets/p2p/.gitignore1
-rw-r--r--tests/sockets/p2p/README.md98
l---------tests/sockets/p2p/bin/uglifyjs1
-rw-r--r--tests/sockets/p2p/examples/data-demo.html16
-rw-r--r--tests/sockets/p2p/examples/data-demo.js103
-rw-r--r--tests/sockets/p2p/examples/list.html112
l---------tests/sockets/p2p/forever1
-rw-r--r--tests/sockets/p2p/package.json9
-rw-r--r--tests/test_sockets.py1
9 files changed, 4 insertions, 338 deletions
diff --git a/tests/sockets/p2p/.gitignore b/tests/sockets/p2p/.gitignore
index a2647ce2..065a4ac0 100644
--- a/tests/sockets/p2p/.gitignore
+++ b/tests/sockets/p2p/.gitignore
@@ -1 +1,2 @@
+node_modules
ssl
diff --git a/tests/sockets/p2p/README.md b/tests/sockets/p2p/README.md
deleted file mode 100644
index 52d383dd..00000000
--- a/tests/sockets/p2p/README.md
+++ /dev/null
@@ -1,98 +0,0 @@
-# WebRTC peer-to-peer
-
-This is a browser JS library that makes it easy to manage RTC peer connections, streams and data channels.
-It's currently used in [emscripten](http://github.com/kripken/emscripten) to provide data transport for the posix sockets implementation.
-
-## Requirements
-
-You will need either Firefox [Nightly](http://nightly.mozilla.org/), or Chrome [Canary](https://www.google.com/intl/en/chrome/browser/canary.html).
-You can also use Chrome [Dev Channel](http://www.chromium.org/getting-involved/dev-channel).
-
-## What it does
-
-* Firefox (nightly) and Chrome (dev/canary) supported
-* Binary transport using arraybuffers (Firefox only!)
-* Multiple connections
-* Broker service (on nodejitsu), or run your own
-* Connection timeouts
-
-## What it doesn't do (yet!)
-
-* Interoperability between Firefox and Chrome
-* Peer brokering for establishing new connections through existing peer-to-peer
-
-## Quick start
-
-Setting up a peer is easy. The code below will create a new peer and listen for incoming connections.
-The `onconnection` handler is called each time a new connection is ready.
-
-````javascript
-// Create a new Peer
-var peer = new Peer(
- 'http://webrtcb.jit.su:80', // You can use this broker if you don't want to set one up
- {
- binaryType: 'arraybuffer',
- video: false,
- audio: false
- }
-);
-
-// Listen for incoming connections
-peer.listen();
-
-var connections = {};
-
-// Handle new connections
-peer.onconnection = function(connection) {
- // Store connections here so we can use them later
- connections[connection.id] = connection; // Each connection has a unique ID
-
- connection.ondisconnect = function(reason) {
- delete connections[connection.id];
- };
-
- connection.onerror = function(error) {
- console.error(error);
- };
-
- // Handle messages from this channel
- // The label will be 'reliable' or 'unreliable', depending on how it was received
- connection.onmessage = function(label, message) {
- console.log(label, message);
- };
-
- // Sends a message to the other peer using the reliable data channel
- connection.send('reliable', 'hi!');
-
- // The connection exposes the underlying media streams
- // You can attach them to DOM elements to get video/audio, if available
- console.log(connection.streams.local, connection.streams.remote);
-
- // Closes the connection
- // This will cause `ondisconnect` to fire
- connection.close();
-};
-
-// Print our route when it's available
-peer.onroute = function(route) {
- // This is our routing address from the broker
- // It's used by peers who wish to connect with us
- console.log('route:', route);
-};
-
-peer.onerror = function(error) {
- console.log(error);
-};
-````
-
-Another peer can connect easily to the one we made above by calling `connect()` on its routing address.
-
-````javascript
-peer.connect(route);
-````
-
-## Demo
-
-There are some files in the `demo` directory that offer an example.
-You can load it [here](http://js-platform.github.com/p2p/examples/data-demo.html) and open the `connect` URL in another window.
-For this example, the `route` is added to the URL query string so that the other peer can parse it and connect when the page loads, so all you need to share is the URL.
diff --git a/tests/sockets/p2p/bin/uglifyjs b/tests/sockets/p2p/bin/uglifyjs
deleted file mode 120000
index 94aae288..00000000
--- a/tests/sockets/p2p/bin/uglifyjs
+++ /dev/null
@@ -1 +0,0 @@
-../node_modules/.bin/uglifyjs \ No newline at end of file
diff --git a/tests/sockets/p2p/examples/data-demo.html b/tests/sockets/p2p/examples/data-demo.html
deleted file mode 100644
index eb61af9e..00000000
--- a/tests/sockets/p2p/examples/data-demo.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8" />
-</head>
-<body>
- <div>instructions: open the connect link in a new window or tab; after a few seconds you should see a message in both instances indicating that they are connected</div>
- <video id="local" autoplay></video>
- <video id="remote" autoplay></video>
- <div id="host"></div>
- <pre id="chat"></pre>
- <input type="text" id="chatinput">
-</body>
-<script src="../client/p2p-client.js"></script>
-<script src="data-demo.js"></script>
-</html>
diff --git a/tests/sockets/p2p/examples/data-demo.js b/tests/sockets/p2p/examples/data-demo.js
deleted file mode 100644
index 86fe2fa9..00000000
--- a/tests/sockets/p2p/examples/data-demo.js
+++ /dev/null
@@ -1,103 +0,0 @@
-function log(msg) {
- console.log(msg);
- document.getElementById("chat").appendChild(document.createTextNode(msg + "\n"));
-}
-
-/*
-var localvideo = document.getElementById("local");
-var remotevideo = document.getElementById("remote");
-*/
-
-function bindStream(stream, element) {
- if ("mozSrcObject" in element) {
- element.mozSrcObject = stream;
- } else {
- element.src = webkitURL.createObjectURL(stream);
- }
- element.play();
-};
-
-var brokerSession = null;
-var brokerUrl = 'https://mdsw.ch:8080';
-var hosting = true;
-var options;
-
-if(window.location.search) {
- var params = window.location.search.substring(1).split('&');
- for(var i = 0; i < params.length; ++ i) {
- if(params[i].match('^webrtc-session')) {
- brokerSession = params[i].split('=')[1];
- hosting = false;
- } else if(params[i].match('^webrtc-broker')) {
- brokerUrl = params[i].split('=')[1];
- }
- }
-}
-
-console.log('broker', brokerUrl);
-var peer = new Peer(brokerUrl, {video: false, audio: false});
-window.connections = {};
-peer.onconnection = function(connection) {
- log('connected: ' + connection.id);
- connections[connection.id] = connection;
- connection.ondisconnect = function() {
- log('disconnected: ' + connection.id);
- delete connections[connection.id];
- };
- connection.onerror = function(error) {
- console.error(error);
- };
-
- //bindStream(connection.streams['local'], localvideo);
- //bindStream(connection.streams['remote'], remotevideo);
-
- connection.onmessage = function(label, msg) {
- log('<other:' + connection.id + '> ' + msg.data);
- };
- /*
- var buff = new Uint8Array([1, 2, 3, 4]);
- connection.send('reliable', buff.buffer);
- */
-};
-peer.onerror = function(error) {
- console.error(error);
-};
-
-if(hosting) {
- console.log('hosting');
- peer.listen({metadata:{name:'data-demo'}});
- peer.onroute = function(route) {
- var url = window.location.toString().split('?');
- url[1] = url[1] || '';
- var params = url[1].split('&');
- params.push('webrtc-session=' + route);
- url[1] = params.join('&');
-
- var div = document.getElementById('host');
- div.innerHTML = '<a href="' + url.join('?') + '">connect</a>';
- }
-} else {
- peer.connect(brokerSession);
-}
-
-window.onbeforeunload = function() {
- var ids = Object.keys(connections);
- ids.forEach(function(id) {
- connections[id].close();
- });
- peer.close();
-};
-
-document.getElementById("chatinput").addEventListener("keyup", function(e) {
- if (e.keyCode == 13) {
- var ci = document.getElementById("chatinput");
- log("<self> " + ci.value);
-
- var ids = Object.keys(connections);
- ids.forEach(function(id) {
- connections[id].send('reliable', ci.value);
- });
-
- ci.value = "";
- }
-});
diff --git a/tests/sockets/p2p/examples/list.html b/tests/sockets/p2p/examples/list.html
deleted file mode 100644
index fa9a6b51..00000000
--- a/tests/sockets/p2p/examples/list.html
+++ /dev/null
@@ -1,112 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8" />
-</head>
-<body>
- <div id="list">
- </div>
-</body>
-<script src="http://wrtcb.jit.su/socket.io/socket.io.js"></script>
-<script>
- var brokerUrl = 'https://mdsw.ch:8080';
- if(window.location.search) {
- var params = window.location.search.substring(1).split('&');
- for(var i = 0; i < params.length; ++ i) {
- if(params[i].match('^webrtc-broker')) {
- brokerUrl = params[i].split('=')[1];
- }
- }
- }
-
- console.log(brokerUrl);
-
- var hosts = {};
- var filter = {
- 'metadata': {
- 'name': '.*'
- }
- };
-
- var socket = io.connect(brokerUrl + '/list');
- socket.on('connect', function() {
- socket.emit('list', filter);
- });
- socket.on('error', function(error) {
- console.error(error);
- });
- socket.on('truncate', function(list) {
- clear();
- append(list);
- });
- socket.on('append', function(host) {
- append([host]);
- });
- socket.on('update', function(host) {
- update([host]);
- });
- socket.on('remove', function(route) {
- remove([route]);
- });
-
- function setQuery(url, item) {
- var urlParts = url.split('?');
- if(urlParts.length < 2) {
- urlParts[1] = item;
- } else {
- var query = urlParts[1].split('&');
- query.push(item);
- urlParts[1] = query.join('&');
- }
- return urlParts.join('?');
- };
-
- function clear() {
- hosts = {};
- var div = document.getElementById('list');
- var parent = div.parentNode;
- parent.removeChild(div);
- div = document.createElement('div');
- div.id = 'list';
- parent.appendChild(div);
- };
-
- function append(list) {
- list = list || [];
- list.forEach(function(host) {
- hosts[host['route']] = host;
- var div = document.getElementById('list');
- var element = document.createElement('div');
- host.element = element;
- var name = host['metadata']['name'] || '';
- var url = setQuery(host['url'], 'webrtc-session=' + host['route']);
- element.innerHTML = new Date(host['ctime']).toString() + ' | ' + name + ' | ' + '<a href="' + url + '">join</a>';
- div.appendChild(element);
- });
- };
-
- function update(list) {
- list = list || [];
- list.forEach(function(host) {
- if(hosts[host['route']]) {
- var element = hosts[host['route']].element;
- var name = host['metadata']['name'] || '';
- var url = setQuery(host['url'], 'webrtc-session=' + host['route']);
- element.innerHTML = new Date(host['ctime']).toString() + ' | ' + name + ' | ' + '<a href="' + url + '">join</a>';
- host.element = element;
- hosts[host['route']] = host;
- }
- });
- };
-
- function remove(list) {
- list = list || [];
- list.forEach(function(route) {
- var host = hosts[route];
- var element = host.element;
- element.parentNode.removeChild(element);
- delete hosts[route];
- });
- };
-</script>
-</html>
diff --git a/tests/sockets/p2p/forever b/tests/sockets/p2p/forever
deleted file mode 120000
index 7913571b..00000000
--- a/tests/sockets/p2p/forever
+++ /dev/null
@@ -1 +0,0 @@
-node_modules/.bin/forever \ No newline at end of file
diff --git a/tests/sockets/p2p/package.json b/tests/sockets/p2p/package.json
index c22f289b..e94eef45 100644
--- a/tests/sockets/p2p/package.json
+++ b/tests/sockets/p2p/package.json
@@ -3,16 +3,11 @@
"version": "0.0.1-21",
"private": true,
"scripts": {
- "start": "node broker/p2p-broker.js",
- "install-windows-service": "winser -i",
- "uninstall-windows-service": "winser -r"
+ "start": "node broker/p2p-broker.js"
},
"dependencies": {
"lodash": "~1.0.1",
- "forever": "~0.10.0",
- "socket.io": "~0.9.13",
- "uglify-js": "~2.2.5",
- "winser": "~0.1.3"
+ "socket.io": "~0.9.13"
},
"engines": {
"node": "0.8.x",
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index e781c652..e3a5573d 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -403,6 +403,7 @@ class sockets(BrowserCore):
Popen([PYTHON, EMCC, temp_host_filepath, '-o', host_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'host_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1']).communicate()
Popen([PYTHON, EMCC, temp_peer_filepath, '-o', peer_outfile] + ['-s', 'GL_TESTING=1', '--pre-js', 'peer_pre.js', '-s', 'SOCKET_WEBRTC=1', '-s', 'SOCKET_DEBUG=1']).communicate()
+ Popen(['npm', 'install', path_from_root('tests', 'sockets', 'p2p')]).communicate();
broker = Popen([NODE_JS, path_from_root('tests', 'sockets', 'p2p', 'broker', 'p2p-broker.js')]);
expected = '1'