Hi,
I am unsure if I am using this library correctly, I'm admittedly new to simple-peer altogether and recently discovered your library. I am trying to send multiple files from one browser to another (one at a time).
I managed to get multiple files to send with the following workflow:
- When User A presses the send button, User A calls:
peer.send('PREPARING_TO_SEND');
- When User B receives the message, User B calls:
peer.on('data', data => {
if (data === 'PREPARING_TO_SEND') {
spf.receive(peer, `photo_${numPhotos}`).then(transfer => {
transfer.on('done', file => {
this.addPhoto(file);
});
});
peer.send('READY_FOR_FILE');
}
})
- When User A receives the message, User A calls:
peer.on('data', data => {
if (data === 'READY_FOR_FILE') {
spf.send(peer, `photo_${numPhotos}`, this.fileToSend).then(transfer => {
transfer.on('done', () => {
numPhotos++;
this.fileToSend = null;
});
transfer.start()
})
}
})
This all seems to work, but every photo sent I get the following console error:
Uncaught TypeError: Cannot read property 'cancel' of null
at Peer.<anonymous> (index.js:60)
Where line 60 is here:
pfs.on('done', destroy);
pfs.on('cancel', destroy);
fileChannel.on('close', function () {
----> pfs.cancel();
});
What's going on here? Do I need to call spf.receive before each file like I'm doing? I tried just calling it once but I got the same error where the file channel would close.
There are no errors coming from my server (and neither user has left the room), and the receiver browser has no errors either
Hi,
I am unsure if I am using this library correctly, I'm admittedly new to simple-peer altogether and recently discovered your library. I am trying to send multiple files from one browser to another (one at a time).
I managed to get multiple files to send with the following workflow:
peer.send('PREPARING_TO_SEND');This all seems to work, but every photo sent I get the following console error:
Where line 60 is here:
What's going on here? Do I need to call spf.receive before each file like I'm doing? I tried just calling it once but I got the same error where the file channel would close.
There are no errors coming from my server (and neither user has left the room), and the receiver browser has no errors either