subins2000 / simple-peer-files

A library to send files over WebRTC
Mozilla Public License 2.0
35 stars 9 forks source link

ArrayBuffer is stored in memory? #1

Closed vj-abishek closed 4 years ago

vj-abishek commented 4 years ago

@subins2000 First of all thanks for this package. I noticed that you are storing ArrayBuffer in memory while transferring remotely, which isn't efficient. Do you have a better way?

And also, noticed that you are using the promise spf.send(peer, 'myFileID', file).then(transfer) But inside the promise, you are using events. In a react app it is causing issue.

maxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 destroy listeners added. Use emitter.setMaxListeners() to increase limit

If it uses events means, I can do something like this

useEffect(() => {
    const update = (newData) => {
      setMessage([...message, newData])    
    }
    peer.on('data',  update)
  return () => peer.off('data', update);
  }, [message])

But I cannot off the event while unmounting, do you have any solution?

And also do you know anything regarding this issue https://github.com/feross/simple-peer/issues/748#issue-724332655

vj-abishek commented 4 years ago

found the answer to all of those, so closing this issue

Jatinkabariya commented 1 year ago

found the answer to all of those, so closing this issue

what is the answer?