diff options
author | Marvin Borner | 2019-01-22 19:40:53 +0100 |
---|---|---|
committer | Marvin Borner | 2019-01-22 19:40:53 +0100 |
commit | 92648c3e1b8b15d5edfd3f8d6e9c28b486ba6364 (patch) | |
tree | dab10afb1f0a809d5366197e2699b623a302f15a /public | |
parent | 9eca06d0f79c24618a0813edd8ab31f1c6532f20 (diff) |
Added functionality
Diffstat (limited to 'public')
-rw-r--r-- | public/scripts/main.js | 13 |
1 files changed, 8 insertions, 5 deletions
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())); }); |