From 92648c3e1b8b15d5edfd3f8d6e9c28b486ba6364 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 22 Jan 2019 19:40:53 +0100 Subject: Added functionality --- public/scripts/main.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'public') diff --git a/public/scripts/main.js b/public/scripts/main.js index 45e3c79..d0d6073 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -4,12 +4,15 @@ const nanoid = require('nanoid'); const userId = nanoid(); const peer = new Peer(userId, {host: '127.0.0.1', port: 4242, path: '/', debug: 3}); -// LOG -peer.on('open', id => console.log('[LOG] Your ID is ' + id)); -peer.on('connection', data => console.log('[LOG] Received data ' + data)); -peer.on('error', err => console.error(err)); +// Peer events +peer.on('open', id => { + console.log('[LOG] Your ID is ' + id); + peer.on('data', data => console.log('[LOG] Received data ' + data)); + peer.on('error', err => console.error(err)); +}); function connect(id) { + console.log('[LOG] Connecting to ' + id); const connectionId = nanoid(); const conn = peer.connect(id, {label: connectionId}); console.log('[LOG] Your connection ID is ' + connectionId); @@ -23,5 +26,5 @@ function connect(id) { * Events after load */ $(document).ready(() => { - $('#user_id_form').on('click', e => connect($('#user_id').text)); + $('#user_id_form').on('click', e => connect($('#user_id').val())); }); -- cgit v1.2.3