sepfy / libpeer

WebRTC Library for IoT/Embedded Device using C
MIT License
804 stars 108 forks source link

How to send Uint8Array data to the peer? (using the 'datachannel' example) #29

Closed alex-chou9 closed 1 year ago

alex-chou9 commented 1 year ago

Excuse my ignorance on the subject... But is there a way to send Uint8Array instead of String to the peer?

In sctp.c, I tried passing an unsigned char array to usrsctp_sendv. [1]https://imgur.com/XzLBlmi But when I check in the browser, the data received by the onmessage is still 'String'. [2]https://imgur.com/xEZhjNb

alex-chou9 commented 1 year ago

Got it.

In sctp.c, just change the htonl(51) to htonl(53), and the browser's onmessage will get the array instead of String.

thanks.