node-webrtc / node-webrtc-examples

MediaStream and RTCDataChannel examples using node-webrtc
508 stars 161 forks source link

Is it possible to have a simpler example here? #35

Open HyperClockUp opened 3 years ago

HyperClockUp commented 3 years ago

All examlpes here confuse me a lot. Too many encapsulations or requires in those examples, so if there is a no-extra-dependency example or just an example that import modules from node_modules directory, will be helpful to me!

Thanks!

markandrus commented 3 years ago

There have been a few requests for "simpler" examples; however, I'm not sure what people actually want. An RTCDataChannel example? See the ping-pong example. An audio/video example? See the audio-video-loopback example.

These examples — and all the other examples — have been structured so that you can focus on experimenting with node-webrtc's APIs without having to worry about exchanging WebRTC offers and answers. Because exchanging WebRTC offers and answers is one of the most boilerplate-y, annoying bits of WebRTC — and everyone does it differently! E.g., by

Since this project is not interested in prescribing a way to exchange WebRTC offers and answers, all that code is isolated to the lib/ folder. Instead, we focus on ways to use node-webrtc (since this is, after all, node-webrtc-examples). To this end, the examples have been written so that you don't have to worry about WebRTC offer and answer exchange. You just need to fulfill two functions: one for the client (beforeAnswer) and one for the server (beforeOffer).

This model makes it really easy to add more and more examples. We have 8 or 9 ATM, depending on how you count.

Perhaps what I have not made easy is

Anyway, perhaps I am speculating… but I'm also writing this for anyone else reading who is curious about this.


I should return to your question: what would you like to see?

mrbar42 commented 3 years ago

It's been a while since this discussion took place, but i think what people mean by "simpler" is - that it wouldn't be a full project. I'm looking for it too.

The examples are very good for learning and showcasing different capabilities and different use cases, but once i've learned, they are no longer beneficial since they rely on so much abstraction. in order to use any of the examples i'll have to use the entire examples project as a boilerplate which is unwanted, i prefer to incorporate it into my existing project.

The missing piece is an example with a single server file and a single client js file, no requiring other local files on either and no browserify and so on - standalone. this could be phrased as the minimal code required for ping pong/audio echo/etc.

will there be duplication? yes, and that's a good thing because standalone examples are very powerful.

ghost commented 3 years ago

@mrbar42

The missing piece is an example with a single server file and a single client js file, no requiring other local files on either and no browserify and so on - standalone. this could be phrased as the minimal code required for ping pong/audio echo/etc.

will there be duplication? yes, and that's a good thing because standalone examples are very powerful.

Any updates on the matter?

mwolfeu commented 12 months ago

Bump. Single files are the way to get started. They are not meant to be efficient, but rather circumscribe all the concepts we have to assimilate in one file. The layers of abstraction just hinder this. Ex: Simple-peer has examples where you have to exchange the offers by copying/pasting JSON. They were dead simple and very clear.