From 2e324b180cc8341709f653da461ddee47c8b76bb Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 28 Mar 2020 22:29:38 -0500 Subject: [PATCH] add some logging options for GUN messages --- js/pacosako_ui.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/js/pacosako_ui.js b/js/pacosako_ui.js index f5c3a8d..1152f96 100644 --- a/js/pacosako_ui.js +++ b/js/pacosako_ui.js @@ -10,15 +10,40 @@ $(function (){ peers: ['https://jessemcdonald.info/gun'], }); + gun._.on('in', function(msg) { + if (window.logGunIn && + (typeof window.logGunIn !== 'function' || + window.logGunIn(msg))) + { + console.log('in msg: ', msg); + } + }); + + gun._.on('out', function(msg) { + if (window.logGunOut && + (typeof window.logGunOut !== 'function' || + window.logGunOut(msg))) + { + console.log('out msg: ', msg); + } + }); + + function debug() { + if (window.logDebug) { + console.log.apply(console, arguments); + } + } + + window.logGunIn = false; + window.logGunOut = false; + window.logDebug = false; + const PS = window.PacoSako; let currentGame = new PS.Game(); let visibleGame = new PS.Game(currentGame); let cancelGameCallback = function() {}; let cancelMetaCallback = function() {}; - //function debug() { console.log.apply(console, arguments); } - function debug() {} - function pieceTypeCode(type) { if (type === PS.KING) { return 'k';