simple peer js connect event does not trigger
ibalaji777 opened this issue · 3 comments
ibalaji777 commented
i used below code in my project
<html>
<body>
<style>
#outgoing {
width: 600px;
word-wrap: break-word;
white-space: normal;
}
</style>
<form>
<textarea id="incoming"></textarea>
<button type="submit">submit</button>
</form>
<pre id="outgoing"></pre>
<script src="simplepeer.min.js"></script>
<script>
const p = new SimplePeer({
initiator: location.hash === '#1',
trickle: false
})
p.on('error', err => console.log('error', err))
p.on('signal', data => {
console.log('SIGNAL', JSON.stringify(data))
document.querySelector('#outgoing').textContent = JSON.stringify(data)
})
document.querySelector('form').addEventListener('submit', ev => {
ev.preventDefault()
p.signal(JSON.parse(document.querySelector('#incoming').value))
})
p.on('connect', () => {
console.log('CONNECT')
p.send('whatever' + Math.random())
})
p.on('data', data => {
console.log('data: ' + data)
})
</script>
</body>
</html>
But this code does not trigger
p.on('connect', () => {
console.log('CONNECT')
p.send('whatever' + Math.random())
})
jzombie commented
Does your console produce any errors? Posting them here would be a start.
Mihai-github commented
+1
Also interested in this one because I also see thee peer.on('connect') event not triggering by itself and happing to make manual rerenders in order to trigger it and get the event working. It does suppose to work by itself, right??
playmono commented
Not working for me as well