In version 9.1.0 and higher, .on("signal") fires, even though the initiator is set to false. This does not happen in version 9.0.0.
Minimal example with 9.1.0 (same behavior as 9.1.1 and 9.1.2)
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DEBUG 9.1.0</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<form>
<input type="button" id="connect" disabled value="Connect"></button>
</form>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/simple-peer/9.1.0/simplepeer.min.js"></script>
<script src="debug.js"></script>
</html>
debug.js:
window.onload = () => {
const SimplePeer = window.SimplePeer
const connectButton = document.getElementById("connect")
connectButton.disabled = false
connectButton.onclick = connectClicked
}
const connectClicked = event => {
event.preventDefault()
navigator.mediaDevices
.getUserMedia({ video: true, audio: true })
.then(function(stream) {
console.debug("Got user media")
peer = new SimplePeer({ initiator: false, stream: stream })
peer.on("signal", data => {
// Peer wants to send signalling data
console.debug(`Send Signal message: ${data}`)
})
})
.catch(function(err) {
console.error(`Could not get user media or other error in setup, ${err}`)
})
}
Current behavior:
Needed behavior:
signal has not firedIf you change the version to 9.0.0, the behavior is correct. However, I couldn't find a changelog (but I'll proceed with that for now as a workaround)
That signal message informs the other peer that negotiation is required. We should skip sending it on the first negotiation though.
Thx! Yes, I was thinking it should not fire at all when it's not the negotiator :)
I'm just going by the docs btw, https://github.com/feross/simple-peer/blob/master/README.md#events, meaning the on(signal) event. Just to be sure, is this behavior still documented as it should be?
Other than that, I managed to get my application together with the workaround release as of now, in about half a day. It's a very nice library to use!
The behaviour will be as documented after that PR merges ^