This commit is contained in:
Mark Nadal 2017-03-23 11:46:49 -07:00
commit 223c1f7029
29 changed files with 1842 additions and 191 deletions

View File

@ -149,7 +149,7 @@ Designed with ♥ by Mark Nadal, the gun team, and many amazing contributors. L
Thanks to the following people who have contributed to GUN, via code, issues, or conversation (this list has quickly become tremendously behind! We'll probably turn this into a dedicated wiki page so you can add yourself): Thanks to the following people who have contributed to GUN, via code, issues, or conversation (this list has quickly become tremendously behind! We'll probably turn this into a dedicated wiki page so you can add yourself):
[agborkowski](https://github.com/agborkowski); **:star:[alanmimms](https://github.com/alanmimms)**; [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); **[BrockAtkinson](https://github.com/BrockAtkinson) ([brunch config](https://github.com/BrockAtkinson/brunch-gun))**; [bromagosa](https://github.com/bromagosa); [coolaj86](https://github.com/coolaj86); [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan); **[forrestjt](https://github.com/forrestjt) ([file.js](https://github.com/amark/gun/blob/master/lib/file.js))**; [gedw99](https://github.com/gedw99); [HelloCodeMing](https://github.com/HelloCodeMing); **[JosePedroDias](https://github.com/josepedrodias) ([graph visualizer](http://acor.sl.pt:9966))**; **[JuniperChicago](https://github.com/JuniperChicago) ([cycle.js bindings](https://github.com/JuniperChicago/cycle-gun))**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc))**; [ndarilek](https://github.com/ndarilek); [onetom](https://github.com/onetom); [phpnode](https://github.com/phpnode); [PsychoLlama](https://github.com/PsychoLlama); **[RangerMauve](https://github.com/RangerMauve) ([schema](https://github.com/gundb/gun-schema))**; **[robertheessels](https://github.com/swifty) ([gun-p2p-auth](https://github.com/swifty/gun-p2p-auth))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [sbeleidy](https://github.com/sbeleidy); **:star:[Sean Matheson](https://github.com/ctrlplusb) ([Observable/RxJS/Most.js bindings](https://github.com/ctrlplusb/gun-most))**; [ssr1ram](https://github.com/ssr1ram); **[Stefdv](https://github.com/stefdv) ([Polymer/web components](http://stefdv.github.io/gun-collection/components/gun-collection/))**; [Xe](https://github.com/Xe); [zot](https://github.com/zot); [ayurmedia](https://github.com/ayurmedia); [agborkowski](https://github.com/agborkowski); **:star:[alanmimms](https://github.com/alanmimms)**; [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); **[BrockAtkinson](https://github.com/BrockAtkinson) ([brunch config](https://github.com/BrockAtkinson/brunch-gun))**; [bromagosa](https://github.com/bromagosa); [coolaj86](https://github.com/coolaj86); [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan); **[forrestjt](https://github.com/forrestjt) ([file.js](https://github.com/amark/gun/blob/master/lib/file.js))**; [gedw99](https://github.com/gedw99); [HelloCodeMing](https://github.com/HelloCodeMing); **[JosePedroDias](https://github.com/josepedrodias) ([graph visualizer](http://acor.sl.pt:9966))**; **[JuniperChicago](https://github.com/JuniperChicago) ([cycle.js bindings](https://github.com/JuniperChicago/cycle-gun))**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc))**; **[kristianmandrup](https://github.com/kristianmandrup) ([edge](https://github.com/kristianmandrup/gun-edge))**; [ndarilek](https://github.com/ndarilek); [onetom](https://github.com/onetom); [phpnode](https://github.com/phpnode); [PsychoLlama](https://github.com/PsychoLlama); **[RangerMauve](https://github.com/RangerMauve) ([schema](https://github.com/gundb/gun-schema))**; **[robertheessels](https://github.com/swifty) ([gun-p2p-auth](https://github.com/swifty/gun-p2p-auth))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [sbeleidy](https://github.com/sbeleidy); **:star:[Sean Matheson](https://github.com/ctrlplusb) ([Observable/RxJS/Most.js bindings](https://github.com/ctrlplusb/gun-most))**; [ssr1ram](https://github.com/ssr1ram); **[Stefdv](https://github.com/stefdv) ([Polymer/web components](http://stefdv.github.io/gun-collection/components/gun-collection/))**; [Xe](https://github.com/Xe); [zot](https://github.com/zot); [ayurmedia](https://github.com/ayurmedia);
This list of contributors was manually compiled and alphabetically sorted. If we missed you, please submit an issue so we can get you added! This list of contributors was manually compiled and alphabetically sorted. If we missed you, please submit an issue so we can get you added!

View File

@ -37,7 +37,7 @@
</script> </script>
<script> <script>
($.model = $('ul li').clone(true)).removeAttribute('class'); ($.model = $('ul li').clone(true)).removeAttribute('class');
var gun = Gun(location.origin + '/gun'); var gun = Gun(location.origin);
var chat = gun.get('example/chat/data'); var chat = gun.get('example/chat/data');
chat.map().val(function(msg, field){ chat.map().val(function(msg, field){
console.log("msg", field, msg); console.log("msg", field, msg);
@ -63,4 +63,4 @@
}; };
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,24 +1,13 @@
console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080; var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8080;
var express = require('express'); var express = require('express');
var http = require('http'); var Gun = require('..');
var app = express();
var server = http.createServer(app);
var Gun = require('../');
var gun = Gun({
file: 'data.json',
web: server,
s3: {
key: '', // AWS Access Key
secret: '', // AWS Secret Token
bucket: '' // The bucket you want to save into
}
});
var app = express();
app.use(Gun.serve); app.use(Gun.serve);
app.use(express.static(__dirname)); app.use(express.static(__dirname));
server.listen(port);
var server = app.listen(port);
Gun({ file: 'data.json', web: server });
console.log('Server started on port ' + port + ' with /gun'); console.log('Server started on port ' + port + ' with /gun');

29
examples/hapi.js Normal file
View File

@ -0,0 +1,29 @@
const Hapi = require('hapi')
const Inert = require('inert')
const Gun = require('..')
const server = new Hapi.Server
server.connection({ port: 8080 })
server.connections.forEach(c => Gun({ web: c.listener, file: 'data.json' }))
server.register(Inert, () => {});
server.route({
method: 'GET',
path: '/gun.js',
handler: (request, reply) => reply.file('../gun.js', { confine: false })
})
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: __dirname,
redirectToSlash: true,
index: true
}
}
})
server.start()

View File

@ -36,7 +36,7 @@ wss.on('connection',acceptConnection )
var gunPeers = []; // used as a list of connected clients. var gunPeers = []; // used as a list of connected clients.
Gun.on('out', function(msg){ Gun.on('out', function(msg){
msg = JSON.stringify({headers:{},body:msg}); msg = JSON.stringify(msg);
gunPeers.forEach( function(peer){ peer.send( msg ) }) gunPeers.forEach( function(peer){ peer.send( msg ) })
}) })
function acceptConnection( connection ) { function acceptConnection( connection ) {
@ -46,7 +46,7 @@ function acceptConnection( connection ) {
gunPeers.push( connection ); gunPeers.push( connection );
connection.on( 'error',function(error){console.log( "WebSocket Error:", error) } ); connection.on( 'error',function(error){console.log( "WebSocket Error:", error) } );
connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg).body)}) connection.on( 'message',function(msg){gun.on('in',JSON.parse( msg))})
connection.on( 'close', function(reason,desc){ connection.on( 'close', function(reason,desc){
// gunpeers gone. // gunpeers gone.
var i = gunPeers.findIndex( function(p){return p===connection} ); var i = gunPeers.findIndex( function(p){return p===connection} );

View File

@ -20,4 +20,4 @@
<a href="/chat/index.html"><iframe src="/chat/index.html"></iframe></a> <a href="/chat/index.html"><iframe src="/chat/index.html"></iframe></a>
<script src="../gun.js"></script> <script src="../gun.js"></script>
</body> </body>
</html> </html>

View File

@ -26,7 +26,7 @@
function clean(text){ return String(text).replace(/\</ig, '&lt;') } function clean(text){ return String(text).replace(/\</ig, '&lt;') }
</script> </script>
<script> <script>
var gun = Gun(location.origin + '/gun'); var gun = Gun(location.origin);
var ref = gun.get('example/json/data'); var ref = gun.get('example/json/data');
$('#form').onsubmit = function(e){ $('#form').onsubmit = function(e){
return ref.path( clean($('#field').value) ).put("value"), false; // add a new field, and cancel the form submit. return ref.path( clean($('#field').value) ).put("value"), false; // add a new field, and cancel the form submit.
@ -75,4 +75,4 @@
} }
</style> </style>
</body> </body>
</html> </html>

View File

@ -1,11 +0,0 @@
{
"presets": [
"react",
"env",
"stage-0"
],
"plugins": [
"transform-decorators-legacy",
"transform-eval"
]
}

View File

@ -1,3 +1,18 @@
data.json # See https://help.github.com/ignore-files/ for more about ignoring files.
node_modules
npm-debug.log # dependencies
/node_modules
# testing
/coverage
# production
/build
# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
import React, { Component } from 'react'
import { render } from 'react-dom'
import Todos from './todos'
import Chat from './chat'
import Json from './json'
const App = _ =>
<div>
<h1>React Examples</h1>
<h2>Todo</h2>
<Todos />
<br />
<hr />
<h2>Chat</h2>
<Chat />
<br />
<hr />
<h2>Json</h2>
<Json />
</div>
render(<App />, document.getElementById('app'))

View File

@ -1,12 +0,0 @@
<!doctype html>
<html>
<head>
<title>Gun - React Examples</title>
<meta charset="utf-8" />
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@ -1,38 +1,22 @@
{ {
"name": "gun-react-examples", "name": "gun-react-examples",
"version": "1.0.0", "version": "1.1.0",
"description": "", "private": true,
"scripts": {
"start": "node start",
"dev": "nodemon --config .nodemon.json start"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-eval": "^6.8.0",
"babel-preset-env": "^1.2.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"css-loader": "^0.26.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.26.0",
"json-loader": "^0.5.4",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.14.0"
},
"dependencies": { "dependencies": {
"babel": "^6.5.2", "gun": "file:../..",
"babel-polyfill": "^6.20.0",
"express": "^4.14.1",
"lodash": "^4.17.4",
"react": "^15.4.2", "react": "^15.4.2",
"react-dom": "^15.4.2", "react-dom": "^15.4.2"
"webpack-dev-middleware": "^1.9.0" },
"devDependencies": {
"express": "^4.15.2",
"express-http-proxy": "^0.11.0",
"react-scripts": "0.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"server": "PORT=8081 node ./server.js"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Gun - React Examples</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
</html>

View File

@ -1,18 +1,26 @@
import express from 'express' console.log("If modules not found, run `npm install` in /example folder!"); // git subtree push -P examples heroku master // OR // git subtree split -P examples master && git push heroku [['HASH']]:master --force
import Gun from '../..' var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8081;
import webpack from 'webpack' var host = process.env.OPENSHIFT_NODEJS_HOST || process.env.VCAP_APP_HOST || process.env.HOST || 'localhost';
import WebpackDevMiddleware from 'webpack-dev-middleware'
import config from './webpack.config' var express = require('express');
var proxy = require('express-http-proxy');
const app = express() var http = require('http');
const gun = Gun() var app = express();
var server = http.createServer(app);
Gun({web: app})
var Gun = require('gun');
const compiler = webpack(config) var gun = Gun({
file: 'data.json',
const devMiddleware = WebpackDevMiddleware(compiler) web: server,
s3: {
app.use(devMiddleware) key: '', // AWS Access Key
secret: '', // AWS Secret Token
app.listen(4000) bucket: '' // The bucket you want to save into
}
});
app.use(Gun.serve);
app.use(proxy(host + ':8080'));
server.listen(port);
console.log('Server started on port ' + port + ' with /gun');

31
examples/react/src/App.js Normal file
View File

@ -0,0 +1,31 @@
import React, { Component } from 'react';
import Todos from './Todos'
import Chat from './Chat'
import Json from './Json'
class App extends Component {
constructor() {
super();
this.gun = Gun(location.origin + '/gun')
}
render() {
return (
<div>
<h1>React Examples</h1>
<h2>Todo</h2>
<Todos gun={this.gun} />
<br />
<hr />
<h2>Chat</h2>
<Chat gun={this.gun} />
<br />
<hr />
<h2>Json</h2>
<Json gun={this.gun} />
</div>
);
}
}
export default App;

View File

@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});

View File

@ -1,7 +1,6 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import Gun from '../../gun' import Gun from 'gun'
const gun = Gun().get('chat')
const formatMsgs = msgs => Object.keys(msgs) const formatMsgs = msgs => Object.keys(msgs)
.map(key => ({ key, ...msgs[key] })) .map(key => ({ key, ...msgs[key] }))
.filter(m => Boolean(m.when) && m.key !== '_') .filter(m => Boolean(m.when) && m.key !== '_')
@ -9,8 +8,9 @@ const formatMsgs = msgs => Object.keys(msgs)
.map(m => ((m.whenFmt = new Date(m.when).toLocaleString().toLowerCase()), m)) .map(m => ((m.whenFmt = new Date(m.when).toLocaleString().toLowerCase()), m))
export default class Chat extends Component { export default class Chat extends Component {
constructor() { constructor({gun}) {
super() super()
this.gun = gun.get('chat');
this.state = { this.state = {
newMsg: '', newMsg: '',
name: (document.cookie.match(/alias\=(.*?)(\&|$|\;)/i)||[])[1]||'', name: (document.cookie.match(/alias\=(.*?)(\&|$|\;)/i)||[])[1]||'',
@ -19,7 +19,7 @@ export default class Chat extends Component {
} }
componentWillMount() { componentWillMount() {
const tmpState = {} const tmpState = {}
gun.map().val((msg, key) => { this.gun.map().val((msg, key) => {
tmpState[key] = msg tmpState[key] = msg
this.setState({msgs: Object.assign({}, this.state.msgs, tmpState)}) this.setState({msgs: Object.assign({}, this.state.msgs, tmpState)})
}) })
@ -32,7 +32,7 @@ export default class Chat extends Component {
document.cookie = ('alias=' + who) document.cookie = ('alias=' + who)
const when = Gun.time.is() const when = Gun.time.is()
const key = `${when}_${Gun.text.random(4)}` const key = `${when}_${Gun.text.random(4)}`
gun.path(key).put({ this.gun.path(key).put({
who, who,
when, when,
what: this.state.newMsg, what: this.state.newMsg,

View File

@ -1,30 +1,29 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import Gun from '../../gun'
const gun = Gun().get('json')
const formatJson = json => const formatJson = json =>
Object.keys(json) Object.keys(json)
.map(key => ({ key, val: json[key]})) .map(key => ({ key, val: json[key]}))
.filter(el => el.key !== '_') .filter(el => el.key !== '_')
export default class Json extends Component { export default class Json extends Component {
constructor() { constructor({gun}) {
super() super()
this.gun = gun.get('json');
this.state = { newField: '', json: [] } this.state = { newField: '', json: [] }
} }
componentWillMount() { componentWillMount() {
gun.on(json => this.setState({ json: formatJson(json) })) this.gun.on(json => this.setState({ json: formatJson(json) }))
} }
edit = key => e => { edit = key => e => {
e.preventDefault() e.preventDefault()
gun.path(key).put(e.target.value) this.gun.path(key).put(e.target.value)
} }
add = e => { add = e => {
e.preventDefault() e.preventDefault()
gun.path(this.state.newField).put('value') this.gun.path(this.state.newField).put('value')
this.setState({newField: ''}) this.setState({newField: ''})
} }

View File

@ -1,28 +1,28 @@
import './style.css' import './style.css'
import React, { Component } from 'react' import React, { Component } from 'react'
import Gun from '../../gun' import Gun from 'gun'
const gun = Gun().get('todos')
const formatTodos = todos => Object.keys(todos) const formatTodos = todos => Object.keys(todos)
.map(key => ({ key, val: todos[key] })) .map(key => ({ key, val: todos[key] }))
.filter(t => Boolean(t.val) && t.key !== '_') .filter(t => Boolean(t.val) && t.key !== '_')
export default class Todos extends Component { export default class Todos extends Component {
constructor() { constructor({gun}) {
super() super()
this.gun = gun.get('todos');
this.state = {newTodo: '', todos: []} this.state = {newTodo: '', todos: []}
} }
componentWillMount() { componentWillMount() {
gun.on(todos => this.setState({ this.gun.on(todos => this.setState({
todos: formatTodos(todos) todos: formatTodos(todos)
})) }))
} }
add = e => { add = e => {
e.preventDefault() e.preventDefault()
gun.path(Gun.text.random()).put(this.state.newTodo) this.gun.path(Gun.text.random()).put(this.state.newTodo)
this.setState({newTodo: ''}) this.setState({newTodo: ''})
} }
del = key => gun.path(key).put(null) del = key => this.gun.path(key).put(null)
handleChange = e => this.setState({ newTodo: e.target.value}) handleChange = e => this.setState({ newTodo: e.target.value})
render() { render() {
return <div> return <div>

View File

@ -0,0 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}

View File

@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);

View File

@ -1,3 +0,0 @@
require('source-map-support').install()
require('babel-register')
require('./server')

View File

@ -1,38 +0,0 @@
var webpack = require('webpack')
var path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './app.js',
devtool: 'source-map',
output: {
filename: '[name].js?[hash]',
path: path.join(__dirname, 'public'),
},
module: {
loaders: [
{
test: /\.css$/,
loader: 'style!css',
},
{
test: /\.(png|gif|jpg|jpeg|woff)$/,
loader: 'url',
},
{
test: /\.(eot|ttf|svg|ico)$/,
loader: 'file',
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: './index.html'
})
],
}

View File

@ -11,7 +11,7 @@
function clean(text){ return String(text).replace(/\</ig, '&lt;') } function clean(text){ return String(text).replace(/\</ig, '&lt;') }
</script> </script>
<script> // by Forrest Tait! Edited by Mark Nadal. <script> // by Forrest Tait! Edited by Mark Nadal.
var gun = Gun(location.origin + '/gun'); var gun = Gun(location.origin);
var todo = gun.get('example/todo/data'); var todo = gun.get('example/todo/data');
$("#add").onsubmit = function(){ $("#add").onsubmit = function(){
todo.path(Gun.text.random()).put(clean($("#todo").value)); // add the HTML input's value to a random ID in the todo. todo.path(Gun.text.random()).put(clean($("#todo").value)); // add the HTML input's value to a random ID in the todo.
@ -34,4 +34,4 @@
} }
</script> </script>
</body> </body>
</html> </html>

9
gun.js
View File

@ -935,6 +935,7 @@
if(!obj_is(at.opt.peers)){ at.opt.peers = {}} if(!obj_is(at.opt.peers)){ at.opt.peers = {}}
at.opt.peers = obj_to(tmp, at.opt.peers); at.opt.peers = obj_to(tmp, at.opt.peers);
} }
at.opt.wsc = at.opt.wsc || {protocols:null}
at.opt.peers = at.opt.peers || {}; at.opt.peers = at.opt.peers || {};
obj_to(opt, at.opt); // copies options on to `at.opt` only if not already taken. obj_to(opt, at.opt); // copies options on to `at.opt` only if not already taken.
Gun.on('opt', at); Gun.on('opt', at);
@ -2343,8 +2344,10 @@
if(!cat.udrain){ return } if(!cat.udrain){ return }
var tmp = cat.udrain; var tmp = cat.udrain;
cat.udrain = null; cat.udrain = null;
message = JSON.stringify(tmp); if( tmp.length ) {
Gun.obj.map(cat.opt.peers, send, cat); message = JSON.stringify(tmp);
Gun.obj.map(cat.opt.peers, send, cat);
}
},1); },1);
wsp.count = 0; wsp.count = 0;
Gun.obj.map(cat.opt.peers, send, cat); Gun.obj.map(cat.opt.peers, send, cat);
@ -2381,7 +2384,7 @@
function open(peer, as){ function open(peer, as){
if(!peer || !peer.url){ return } if(!peer || !peer.url){ return }
var url = peer.url.replace('http', 'ws'); var url = peer.url.replace('http', 'ws');
var wire = peer.wire = new WebSocket(url); var wire = peer.wire = new WebSocket(url, as.opt.wsc.protocols, as.opt.wsc );
wire.onclose = function(){ wire.onclose = function(){
reconnect(peer, as); reconnect(peer, as);
}; };

View File

@ -54,10 +54,12 @@
}, },
"devDependencies": { "devDependencies": {
"express": "~>4.13.4", "express": "~>4.13.4",
"hapi": "^16.1.0",
"inert": "^4.1.0",
"ip": "^1.1.4",
"mocha": "~>1.9.0", "mocha": "~>1.9.0",
"uglify-js": "~>2.2.0",
"panic-manager": "^1.2.0", "panic-manager": "^1.2.0",
"panic-server": "^1.1.0", "panic-server": "^1.1.0",
"ip": "^1.1.4" "uglify-js": "~>2.2.0"
} }
} }