Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master into RAD #702

Merged
merged 158 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
86c4017
new sea test
jadbox Jul 13, 2018
93975a0
Merge pull request #584 from amark/master
amark Jul 13, 2018
158454d
Merge branch 'sea' of https://github.com/amark/gun into sea
jadbox Jul 13, 2018
9ac6d3b
Merge pull request #585 from jadbox/sea
amark Jul 13, 2018
91babdb
progress with @jadbox who setup the tests!
amark Jul 13, 2018
4ecbf44
start doc refactor?
amark Aug 7, 2018
2fe0932
Update README.md
amark Aug 7, 2018
0a81c84
Update README.md
amark Aug 14, 2018
8b482b0
start space, sea leave fix, * test
amark Aug 15, 2018
3996e3c
Index space alpha!
amark Aug 18, 2018
443be3b
Index space in alpha!
amark Aug 18, 2018
9b84e29
fix typo. Index space now in ALPHA! :) :)
amark Aug 18, 2018
0cad0fb
WebRTC!
amark Aug 22, 2018
5a55872
Update README.md
amark Aug 22, 2018
9781877
fix 1 of @mmalmi 's found bug.
amark Aug 24, 2018
84a000f
First version of RAD IndexedDB.
robertheessels Aug 24, 2018
2ebf43e
Merge pull request #601 from amark/rh_rindexed
amark Aug 24, 2018
90feaa5
SEA tweaks
amark Aug 24, 2018
7ab41c0
Merge branch 'master' of http://github.com/amark/gun
amark Aug 24, 2018
aee20eb
RAD indexedDB!
amark Aug 24, 2018
80a9a67
unbuild
amark Aug 24, 2018
5b62437
indexedDB!!! Thanks @robertheessels
amark Aug 24, 2018
2630cc8
Not swearing: DAM @$$ Heisenbug fixed!
amark Aug 24, 2018
001eb6f
Not swearing: DAM @$$ Heisenbug fixed!
amark Aug 24, 2018
8fff5e9
SEA & DAM fix
amark Aug 29, 2018
a4df3c0
npm install gun DO NOT git clone
amark Aug 29, 2018
f7b7778
Couple more SEA fixes
amark Aug 30, 2018
b695bba
Better waiting for IndexedDB ready.
robertheessels Aug 31, 2018
64ab915
Merge pull request #604 from amark/rh
amark Aug 31, 2018
f52aa41
This condition must be true if `data` undefined
rogowski Sep 7, 2018
de3ea9f
Merge branch 'master' into master
rogowski Sep 7, 2018
07fcb2b
Merge pull request #608 from rogowski/master
amark Sep 7, 2018
0c02e76
MetaMask overload
amark Sep 15, 2018
2637b9d
Update README.md
amark Sep 18, 2018
b536a00
Update README.md
amark Sep 19, 2018
0160d1c
Update indexedDB.html
amark Sep 20, 2018
6126f4b
Update indexedDB.html
amark Sep 21, 2018
5289126
fix NodeJS SEA auth w/ PBKDF2
amark Sep 23, 2018
c16c418
fix once, unbuild NAB fix
amark Sep 23, 2018
0144067
Merge branch 'master' of http://github.com/amark/gun
amark Sep 23, 2018
04c731c
Stabilize against V8 fatalities.
amark Sep 25, 2018
c61ab82
get rid of tmp
amark Sep 25, 2018
d269419
unbuild Stabilized against V8 Fatalities.
amark Sep 25, 2018
e59bece
Update README.md
amark Sep 25, 2018
5b44229
Update README.md
amark Sep 25, 2018
5cfa492
Add les.js (Memory Evict)
masterex1000 Sep 26, 2018
4e5b98a
Add les.js (Memory Evict)
masterex1000 Sep 26, 2018
9c7c05a
Merge pull request #614 from masterex1000/master
amark Sep 27, 2018
f1ff3b0
Update README.md
amark Sep 27, 2018
41482d2
SEA User.auth(pair for @mmalmi
amark Oct 1, 2018
e9e595d
Merge pull request #1 from amark/master
rogowski Oct 2, 2018
fffec3c
Fixed 'do not handle lexical cursors'
rogowski Oct 2, 2018
48a8f80
Merge pull request #617 from rogowski/master
amark Oct 2, 2018
84557c7
Update index.js
rogowski Oct 2, 2018
87729e0
at.NTS never been found
ChihChienKung Oct 9, 2018
5be08a0
Merge pull request #623 from ChihChienKung/master
amark Oct 9, 2018
c5dae7a
Fix SEA sha1hash for ossl and keyid
langholz Oct 11, 2018
857149a
Merge pull request #625 from langholz/sea-keyid-fix
amark Oct 11, 2018
774fcc7
once fix, clean sea
amark Oct 11, 2018
7f4b77a
Merge branch 'master' of http://github.com/amark/gun
amark Oct 11, 2018
16ddb8d
Update README.md
amark Nov 4, 2018
16e64e1
MetaMask start, AXE start, SEA refactor, etc.
amark Nov 17, 2018
33283b8
Merge branch 'master' of http://github.com/amark/gun
amark Nov 17, 2018
4896085
quick fix, republish ...999...
amark Nov 18, 2018
0ad2c74
added react-native demo
Shadyzpop Nov 21, 2018
ce85d45
updated the react-native demos readme
Shadyzpop Nov 21, 2018
9c3138a
Merge https://github.com/amark/gun
rogowski Nov 21, 2018
688c9a8
SEA - fix typeof
rogowski Nov 21, 2018
8365739
Merge pull request #639 from Shadyzpop/master
amark Nov 21, 2018
680b2d1
AXE - peer/soul subscribe. In this version the peers receive only dat…
rogowski Nov 21, 2018
cb0fb75
Update README.md
amark Nov 21, 2018
f263b4d
Merge pull request #640 from rogowski/master
amark Nov 21, 2018
7360dbc
readme - document test procedure
kumavis Nov 22, 2018
a0f101b
Begin adding browserify docs
danfinlay Nov 24, 2018
a7c01e2
Fix dependencies for SEA
danfinlay Nov 24, 2018
ab637e5
Merge pull request #641 from kumavis/patch-1
amark Nov 24, 2018
3dc6c77
patch from @bshevchenko
amark Nov 28, 2018
a1131ed
Merge branch 'master' of http://github.com/amark/gun
amark Nov 28, 2018
8483ad6
Merge pull request #643 from danfinlay/browserify-docs
amark Nov 28, 2018
3a376a5
Update README.md
amark Nov 28, 2018
82deba5
turn SEA on by default & make shim deps not optional via @danfinlay @…
amark Nov 29, 2018
ff16aff
Merge branch 'sea' into master
amark Nov 29, 2018
b3245b3
Merge pull request #647 from amark/master
amark Nov 29, 2018
7b6c088
fun party, move P2P Uber start thanks to @dletta
amark Dec 6, 2018
c7547cb
Merge branch 'master' into sea
amark Dec 6, 2018
c5b8374
BREAKING SEA CHANGE: Auto migrate UTF8 to Base64
amark Dec 7, 2018
97722c7
fix Nth subscriptions, localStorage on file:// after Chrome deleted i…
amark Dec 8, 2018
c567aae
Update rfs.js
amark Dec 9, 2018
eeaaed0
Update README.md
amark Dec 12, 2018
1087c98
https://gun.eco/docs/Shuffle-Upgrade
amark Dec 13, 2018
cec473c
Merge pull request #658 from amark/dev
amark Dec 13, 2018
83914df
Merge pull request #659 from amark/sea
amark Dec 13, 2018
ea302a9
allow signing signed data + only do sign transform if new data from s…
amark Dec 14, 2018
286a430
Merge branch 'master' into dev
amark Dec 14, 2018
4b43c67
Fix for UTF8 fallback
bugs181 Dec 14, 2018
513907b
Merge pull request #660 from bugs181/master
amark Dec 14, 2018
34c880f
Merge branch 'master' into sea
amark Dec 14, 2018
ecd8430
Merge @bugs181 's fix #661 from amark/sea
amark Dec 14, 2018
8348f19
bump version on @bugs181 SEA migration/fallback fix
amark Dec 14, 2018
7a75ef6
Update README.md
amark Dec 18, 2018
a9aafa1
monotype / normalize / for future meta editor stuff
amark Dec 19, 2018
996db1a
Merge branch 'master' into dev
amark Dec 19, 2018
3d796b4
fix @ThinkingJoules 's import 'cannot link undefined' error
amark Dec 19, 2018
d2833f3
Merge pull request #664 from amark/dev
amark Dec 19, 2018
7ace727
Fix for bye system
jamesrez Dec 20, 2018
665c7a6
Fix for bye system
jamesrez Dec 20, 2018
9e500f1
Now using msg.mesh.via instead of msg.peer(old way)
jamesrez Dec 20, 2018
547adab
Merge pull request #668 from JamieRez/master
amark Dec 20, 2018
c7333fa
fix for @mmalmi 's Identifi
amark Dec 21, 2018
326a03b
Merge branch 'master' into dev
amark Dec 21, 2018
6246704
version bump for @mmalmi 's fix
amark Dec 21, 2018
a0e9371
unbuild for @mmalmi 's fix
amark Dec 21, 2018
a8f9b0b
Merge pull request #670 from amark/dev
amark Dec 21, 2018
2130460
Merge branch 'master' into dev
amark Dec 24, 2018
b08eac1
dabbles
amark Jan 3, 2019
e057c89
Merge branch 'master' into sea
amark Jan 4, 2019
f9974d5
fix SEA shuffle to ignore GUN data
amark Jan 4, 2019
925aff8
fix SEA shuffle to ignore good GUN data
amark Jan 4, 2019
41f45a9
fix SEA shuffle to ignore good GUN data
amark Jan 4, 2019
cd0b12d
OSSL Memory leak mitigation
go1dfish Jan 4, 2019
c375619
Merge pull request #675 from go1dfish/patch-1
amark Jan 4, 2019
9f9b3e5
unbuild
amark Jan 5, 2019
658583d
Merge branch 'master' into sea
amark Jan 5, 2019
88316e7
Merge branch 'master' of https://github.com/amark/gun
masterex1000 Jan 5, 2019
2c110df
initial tests for SEA corrections
amark Jan 6, 2019
04d46e0
legacy
amark Jan 7, 2019
91bd68e
Fix apparent copy/paste error in rindexed.js
go1dfish Jan 7, 2019
38b65ff
add a bunch options for les.js
masterex1000 Jan 7, 2019
810692e
add options to les.js
masterex1000 Jan 7, 2019
5202824
HUGE LEAP into THE SEA
amark Jan 10, 2019
8b7c963
HUGE LEAP into THE SEA
amark Jan 10, 2019
80153d9
HUGE LEAP into THE SEA
amark Jan 10, 2019
e0d85f0
HUGE LEAP into THE SEA
amark Jan 10, 2019
cb9b4b8
More Changes To Les!
masterex1000 Jan 10, 2019
2462e4f
Fix USELOCALGUN setting from last commit
masterex1000 Jan 10, 2019
111953a
patch + update `.mesh` to _
amark Jan 15, 2019
93e14d8
Merge branch 'master' into sea
amark Jan 15, 2019
535d656
Merge pull request #688 from amark/sea
amark Jan 15, 2019
b51acbf
Merge pull request #679 from masterex1000/master
amark Jan 16, 2019
08b375d
Merge pull request #678 from go1dfish/patch-3
amark Jan 16, 2019
6b54932
Make node-webcrypto-ossl an optional dependency.
71 Jan 16, 2019
a07cfaa
Merge pull request #689 from 71/patch-1
amark Jan 16, 2019
6c08eba
unbuild
amark Jan 16, 2019
428f7e9
Merge branch 'master' into dev
amark Jan 26, 2019
c5cd72a
unbuild
amark Jan 16, 2019
4d40ec7
Merge branch 'master' into dev
amark Jan 27, 2019
ebb7fe8
fix peer not founds
amark Jan 28, 2019
858b5d1
unbuild peer not founds fix
amark Jan 28, 2019
18408f6
Merge pull request #699 from amark/dev
amark Jan 28, 2019
ff28c16
meta not metae
amark Jan 28, 2019
7f4bfd4
Merge branch 'master' into dev
amark Jan 28, 2019
a96a80c
set gun ref with SEA causes race condition while crypto op happen, ca…
amark Jan 31, 2019
b9edb1d
party
amark Jan 31, 2019
2aae735
bump
amark Jan 31, 2019
c5b1906
Merge pull request #700 from amark/dev
amark Jan 31, 2019
c243d71
link and normalize
amark Jan 31, 2019
64e8b03
Merge branch 'master' into dev
amark Jan 31, 2019
1fe9daa
Merge pull request #701 from amark/dev
amark Feb 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ branches:
except:
- debug
node_js:
- 4
- 6
- 8
- 10
cache:
Expand Down
115 changes: 81 additions & 34 deletions README.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions as.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@
}, wait || 200);
}
}
as.sort = function(sort, el) {
var vs = $(el).find('.sort');
vs = (vs[0] && u === vs[0].value)? vs.text() : vs.val();
var id = sort;
var test = id >= vs;
return test ? el : as.sort(sort, el.prev());
as.sort = function sort(id, li){
var num = parseFloat(id);
var id = $(li).find('.sort').text() || -Infinity;
var at = num >= parseFloat(id);
return at ? li : sort(id, li.prev());
}
$(document).on('keyup', 'input, textarea, [contenteditable]', as.wait(function(){
var el = $(this);
Expand Down
99 changes: 99 additions & 0 deletions axe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
;(function(){

/* UNBUILD */
var root;
if(typeof window !== "undefined"){ root = window }
if(typeof global !== "undefined"){ root = global }
root = root || {};
var console = root.console || {log: function(){}};
function USE(arg, req){
return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){
arg(mod = {exports: {}});
USE[R(path)] = mod.exports;
}
function R(p){
return p.split('/').slice(-1).toString().replace('.js','');
}
}
if(typeof module !== "undefined"){ var common = module }
/* UNBUILD */

;USE(function(module){
if(typeof window !== "undefined"){ module.window = window }
var tmp = module.window || module;
var AXE = tmp.AXE || function(){};

if(AXE.window = module.window){ try{
AXE.window.AXE = AXE;
tmp = document.createEvent('CustomEvent');
tmp.initCustomEvent('extension', false, false, {type: "AXE"});
(window.dispatchEvent || window.fireEvent)(tmp);
window.postMessage({type: "AXE"}, '*');
} catch(e){} }

try{ if(typeof common !== "undefined"){ common.exports = AXE } }catch(e){}
module.exports = AXE;
})(USE, './root');

;USE(function(module){

var AXE = USE('./root'), Gun = (AXE.window||{}).Gun || USE('./gun', 1);
(Gun.AXE = AXE).GUN = AXE.Gun = Gun;

Gun.on('opt', function(at){
if(!at.axe){
at.axe = {};
var p = at.opt.peers, tmp;
// 1. If any remembered peers or from last cache or extension
// 2. Fallback to use hard coded peers from dApp
// 3. Or any offered peers.
//if(Gun.obj.empty(p)){
// Gun.obj.map(['http://localhost:8765/gun'/*, 'https://guntest.herokuapp.com/gun'*/], function(url){
// p[url] = {url: url, axe: {}};
// });
//}
// Our current hypothesis is that it is most optimal
// to take peers in a common network, and align
// them in a line, where you only have left and right
// peers, so messages propagate left and right in
// a linear manner with reduced overlap, and
// with one common superpeer (with ready failovers)
// in case the p2p linear latency is high.
// Or there could be plenty of other better options.
console.log("axe", at.opt);
if(at.opt.super){
function verify(msg, send, at) {
var peers = Object.keys(p), puts = Object.keys(msg.put), i, j, peer;
var soul = puts[0]; /// TODO: verify all souls in puts. Copy the msg only with subscribed souls?
for (i=0; i < peers.length; ++i) {
peer = p[peers[i]];
//if (peer.url) {console.log('AXE do not reject superpeers'); send(msg, peer); continue;} /// always send to superpeers?
if (!peer.id) {console.log('AXE peer without id: ', peer); continue;}
if (!Gun.subscribe[soul] || !Gun.subscribe[soul][peer.id]) { console.log('AXE SAY reject msg to peer: %s, soul: %s', peer.id, soul); continue; }
send(msg, peer);
}
}
AXE.say = function(msg, send, at) {
if (!msg.put) { send(msg); return; }
console.log('AXE HOOK!! ', msg);
verify(msg, send, at);
};
/// TODO: remove peer from all Gun.subscribe. On `mesh.bye` event?
}
if(at.opt.super){
at.on('in', USE('./lib/super', 1), at);
} else {
//at.on('in', input, at);
}
}
this.to.next(at); // make sure to call the "next" middleware adapter.
});

function input(msg){
var at = this.as, to = this.to;
}

module.exports = AXE;
})(USE, './axe');

}());
40 changes: 40 additions & 0 deletions examples/axe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>Testing AXE</title>
</head>

<body>
<script src="../gun.js"></script>
<!-- <script src="../axe.js"></script> -->
<!-- <script src="../sea.js"></script> -->
<script>
var pid = location.hash.slice(1);

var opt = ({
peers: [`${location.origin}/gun`]
});

if (pid) { opt.pid = pid; }

Gun.on('opt', function(ctx) {
this.to.next(ctx);
ctx.on('hi', function(opt) {
console.log('HI!! PEER', new Date(), opt.pid);
});
if (pid) {
ctx.on('out', function(msg) {
msg.pid = pid;
this.to.next(msg);
});
}
});

var gun = Gun(opt);
//var user = gun.user();
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions test/tmp/li.html → examples/basic/private.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ <h1>Profile</h1>
<script src="https://cdn.jsdelivr.net/npm/gun/examples/jquery.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/open.js"></script>

<script>
//var gun = Gun();
Expand Down Expand Up @@ -104,7 +103,6 @@ <h1>Profile</h1>
$('#profile input').on('keyup', function(e){
if(!user.is){ return }
var id = LI.busy = $(this).attr('id');
console.log("Huh?", id, user);
user.get('profile').get(id).secret($(this).val());
}).on('blur', function(){ LI.busy = false })

Expand Down
50 changes: 50 additions & 0 deletions examples/basic/space.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<h1>Search</h1>

<form id="ask">
<input id="search" placeholder="search..." autocomplete="off">
</form>

<div id="answer"></div>
<ul></ul>

<small>Note: No data is indexed by default, you need to add some!</small>

<script src="../../examples/jquery.js"></script>
<script src="../../gun.js"></script>
<script src="../../sea.js"></script>
<script src="../../lib/space.js"></script>

<script>
var gun = Gun();
var ask = {};

$('#search').on('keyup', function(e){
ask.now = (this.value||'').toLowerCase().replace(/[\W_]+/g,"");
if(ask.last === ask.now){ return }
ask.last = ask.now;
clearTimeout(ask.to);
ask.to = setTimeout(search, 20);
});

function search(){
var key = ask.now;
gun.get('Q').space(key, function(ack){
if(!ack || key !== ask.now){ return }
UI(ack)
});
}

function UI(ack){
$('#answer').text(ack.data || '');
var $ul = $('ul').empty(), tree = ack.tree;
Gun.obj.map(tree, function(v,k){
$('<li>').text(k +' - ' + v).appendTo($ul);
});
};

function load(DATA){
Gun.obj.map(DATA, function(v,k){
gun.get('Q').space(k, v);
});
}
</script>
File renamed without changes.
28 changes: 15 additions & 13 deletions test/tmp/user.html → examples/basic/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,42 @@ <h1>User</h1>
<input id="pass" type="password" placeholder="passphrase">
<input id="in" type="submit" value="sign in">
<input id="up" type="button" value="sign up">
<input id="mask" type="button" value="Identifi Login">
</form>

<ul></ul>

<form id="said">
<input id="say">
<input id="speak" type="button" value="speak">
<input id="speak" type="submit" value="speak">
</form>

<script src="../../examples/jquery.js"></script>
<script src="../../gun.js"></script>
<script src="../../sea.js"></script>
<script src="../jquery.js"></script>
<script src="../../../gun/gun.js"></script>
<script src="../../../gun/sea.js"></script>

<script>
var gun = Gun();
var user = gun.user();
var gun = Gun(); //Gun(['http://localhost:8765/gun', 'https://guntest.herokuapp.com/gun']);
var user = gun.user().recall({sessionStorage: true});

$('#up').on('click', function(e){
user.create($('#alias').val(), $('#pass').val());
user.create($('#alias').val(), $('#pass').val(), login);
});

$('#sign').on('submit', function(e){
e.preventDefault();
function login(e){
user.auth($('#alias').val(), $('#pass').val());
});
return false; // e.preventDefault();
};
$('#sign').on('submit', login);
$('#mask').on('click', login);

gun.on('auth', function(){
$('#sign').hide();
user.get('said').map().val(UI);
user.get('said').map().on(UI);
});

$('#said').on('submit', function(e){
e.preventDefault();
if(!user.is){ return }
//if(!user.is){ return }
user.get('said').set($('#say').val());
$('#say').val("");
});
Expand Down
6 changes: 5 additions & 1 deletion examples/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ console.log("If module not found, install express globally `npm i express -g`!")
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8765;
var express = require('express');
var Gun = require('..');
require('../axe');

var app = express();
app.use(Gun.serve);
app.use(express.static(__dirname));

var server = app.listen(port);
Gun({ file: 'data.json', web: server });
var gun = Gun({ file: 'data', web: server });

global.Gun = Gun; /// make global to `node --inspect` - debug only
global.gun = gun; /// make global to `node --inspect` - debug only

console.log('Server started on port ' + port + ' with /gun');
31 changes: 27 additions & 4 deletions examples/game/space.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
<div class="laser"></div>
</div>
</div>
<p id="debug" style="position: fixed; bottom: 0px; color: white; height: 1em;"></p>
<script src="../jquery.js"></script>
<script src="/gun.js"></script>
<script src="/gun/nts.js"></script>
<script src="../../../gun/gun.js"></script>
<script src="../../../gun/nts.js"></script>
<script src="../../../gun/lib/webrtc.js"></script>
<script>
// Thanks to https://github.com/dmcinnes/HTML5-Asteroids
//var gun = Gun();
var gun = Gun(location.origin+'/gun');
var gun = Gun(location.host? location.origin+'/gun' : 'http://localhost:8765/gun');
var game = {gun: gun.get('example/game/space'), area: {}, ships: {}};
game.keys = {38: 'up', 37: 'left', 39: 'right', 40: 'down', 32: 'space'};
$(document).on('keydown', function(e){
Expand Down Expand Up @@ -178,14 +180,14 @@
game.start = function(){
game.now = Gun.state();
game.resize();
game.ship();
game.gun.get('players').map().on(function(data, id){
data = Gun.obj.copy(data);
data.x = data.x * game.area.x;
data.y = data.y * game.area.y;
data.id = data.id || id;
game.ship(data);
});
game.ship();
var frame = game.frame, ships = game.ships;
var last = game.now, now, diff, delta;
setInterval(game.sync, 99);
Expand All @@ -203,6 +205,27 @@
$(function(){
game.start();
});

// test WebRTC
gun.on('hi', function(peer){
console.log("hi!", peer);
if(peer.url){ return }
Gun.obj.map(gun.back('opt.peers'), function(peer){
if(!peer.url || !peer.wire){ return }
peer.wire._send = peer.wire.send;
peer.wire.send = send;
var tmp = 'GOBBLE GOBBLE: Not sending any non-WebRTC messages to ' + peer.url;
console.log(tmp);
$('#debug').text(tmp);
});
});
function send(raw){
if(!raw){ return }
if(raw.indexOf('webrtc') >= 0){
if(!this._send){ return }
return this._send(raw);
}
}
</script>
<style>
html, body {
Expand Down
Loading