paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.81k stars 365 forks source link

Nodejs wrapper #122

Closed ptesavol closed 4 years ago

ptesavol commented 4 years ago

Do you know if there is a Nodejs (native) wrapper available for libdatachannel, or if somebody is working on it already?

paullouisageneau commented 4 years ago

I'm not aware of someone working on a node.js wrapper yet.

There is still node-webrtc providing full WebRTC bindings, but I guess the idea with libdatachannel is to require a lighter dependency instead, right?

murat-dogan commented 4 years ago

Actually this is in my mind as an idea, not started yet. I used node-webrtc before.

ptesavol commented 4 years ago

I would be very cool to have more alternatives to node-webrtc. Not that there is anything wrong with node-webrtc, but having more alternatives would make it easier to find out whether a bug is in your own code or in the WebRTC lib you are using.

ptesavol commented 4 years ago

I wonder would it be possible to use https://github.com/paullouisageneau/datachannel-wasm as a basis for Nodejs native lib? Could it even possible to use some emscripten magic to directly build a version of datachannel-wasm for Nodejs?

paullouisageneau commented 4 years ago

Actually what you want here is the reverse wrapper compared to datachannel-wasm, so I don't think anything is reusable.

datachannel-wasm is a wrapper exposing a libdatachannel-compatible C++ interface for the JS webRTC API present in browsers. What would be needed for nodejs is a JS interface for the C API of libdatachannel.

murat-dogan commented 4 years ago

Hi,

Please check my initial version of nodejs wrapper. https://github.com/murat-dogan/node-datachannel

Please check it & tell me what you think.

For now it is building libdatachannel with default options (libjuice etc...) but I will add others as options.

paullouisageneau commented 4 years ago

Great, it looks very promising :+1:

Is there a reason why callbacks are passed in constructor rather than registered on the object with something like on(event, callback)?

murat-dogan commented 4 years ago

Actually there is no special thing. I thought it would be more practical but to separate them could be cleaner.

murat-dogan commented 4 years ago

Separated callbacks looks cleaner. Thanks.

ptesavol commented 4 years ago

This is excellent news @murat-dogan ! I'll try it out.

paullouisageneau commented 4 years ago

@murat-dogan I've linked your wrapper from libdatachannel's readme!

murat-dogan commented 4 years ago

Thanks!