Hi,
I am trying to replicate the webcam example [https://github.com/prcolaco/webcam-stream-libp2p]. I am able to connect with with other peers but cannot stream data to other connected peers. I have used ‘it-pipe’ to stream data to other connected peers. I cannot figure out where am wrong. Please help me.
Also please suggest me a protocol for this application.
App.js
node.connectionManager.on('peer:connect', (connection) => {
console.log("Ccconnected to " + connection.remotePeer.toB58String())
connpeer = connection.remotePeer.toB58String();
; (async () => {
const { stream } = await connection.newStream('/secio/1.0.0');
const p = pushable();
pipe(p,stream);
_OPEN_CONNECTIONS[id] = p;
App.createCanvas(connection.remotePeer.toB58String());
})();
})
................................
................................
node.handle('/secio/1.0.0', ({ stream }) => {
console.log("enter in peer:" + connpeer)
pipe(
stream,
async function (source) {
for await (const data of source) {
if (connpeer !== undefined) {
const canvas = App.getCanvas(connpeer);
if (canvas !== undefined) {
const dataToRender = new ImageData(new Uint8ClampedArray(data), SIZES.width, SIZES.height)
canvas.putImageData(dataToRender, 0, 0);
}
}
}
}
)
})