Simple-peer, only calls the send method once, and the callback in ondata is triggered many times. Why?

using the simple-peer library, there is an instance peer.
binds to events peer.on ("data",func)
and then calls peer.send (data) , data is a relatively large data

at this point, you will find that func will be called multiple times. It seems that data is split into multiple chunk, and then func is executed on each chunk.

The

document says that simple-peer inherits node"s stream-Duplex , but doesn"t quite understand node"s stream, so it feels confused.

how do I know that the current chunk is the last? Because only when the complete data are obtained should we proceed to the next step.

Mar.14,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46245-44ba3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46245-44ba3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?