You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using simple-peer and simple-signal to connect two clients with webcams.
After creating peer connection and passing MediaStream to it, there is no video on the receiving side, just transparent/black square.
Server side:
`const signalServer = require('simple-signal-server')(io)
const allIDs = new Set()
Client side (Vue.js)
`var SimpleSignalClient = require("simple-signal-client");
var signalClient = new SimpleSignalClient(this.$socket.client); // Uses an existing socket.io-client instance
function promptUserForID(ids) {
console.log(ids);
return ids[0];
}
signalClient.on("discover", async (allIDs) => {
const id = await promptUserForID(allIDs); // Have the user choose an ID to connect to
const { peer, metadata } = await signalClient.connect(id); // connect to target client , { asd: 123 }, { stream: stream }
console.log(metadata);
console.log("initiator", peer); // this is a fully-signaled simple-peer object (initiator side)
peer.addStream(stream);
peer.on("stream", (s) => {
var video = document.getElementById("remote1");
console.log(video);
if ("srcObject" in video) {
console.log(1);
video.srcObject = s;
} else {
console.log(1);
video.src = window.URL.createObjectURL(s); // for older browsers
}
});
peer.on("error", (err) => {
console.log(err);
});
});
//console.log(stream);
signalClient.on("request", async (request) => {
const { peer, metadata } = await request.accept(); // Accept the incoming request
console.log(metadata);
peer.addStream(stream);
console.log("answer", peer); // this is a fully-signaled simple-peer object (non-initiator side)
peer.on("stream", (s) => {
console.log("stream");
console.log(s);
var video = document.getElementById("remote1");
console.log(video);
if ("srcObject" in video) {
console.log(1);
video.srcObject = s;
} else {
console.log(1);
video.src = window.URL.createObjectURL(s); // for older browsers
}
});
peer.on("error", (err) => {
console.log(err);
});
});
signalClient.discover();`
The text was updated successfully, but these errors were encountered:
I am using simple-peer and simple-signal to connect two clients with webcams.
After creating peer connection and passing MediaStream to it, there is no video on the receiving side, just transparent/black square.
Server side:
`const signalServer = require('simple-signal-server')(io)
const allIDs = new Set()
signalServer.on('discover', (request) => {
const clientID = request.socket.id
allIDs.add(clientID)
request.discover(Array.from(allIDs))
})
signalServer.on('disconnect', (socket) => {
const clientID = socket.id
allIDs.delete(clientID)
})
signalServer.on('request', (request) => {
request.forward()
})`
Client side (Vue.js)
`var SimpleSignalClient = require("simple-signal-client");
var signalClient = new SimpleSignalClient(this.$socket.client); // Uses an existing socket.io-client instance
The text was updated successfully, but these errors were encountered: