node-webrtc-examples icon indicating copy to clipboard operation
node-webrtc-examples copied to clipboard

Is it possible to have a simpler example here?

Open HyperClockUp opened this issue 3 years ago • 4 comments

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!

HyperClockUp avatar Sep 27 '20 07:09 HyperClockUp

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

  • Using SIP
  • Using JSON over WebSocket
  • Using HTTP
  • Copying/pasting (quickly!)

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

  • Understanding how to add new examples — maybe we just need to better document in the README.md.
  • Forking this repo and building an application on top of it — I'm not sure if people want/expect this, but I'm pretty uninterested in this.
  • Understanding how to use the standard WebRTC APIs themselves — This is also not the point of this project, since there are also plenty of WebRTC tutorials out there and, with the exception of a few nonstandard additions and omissions, node-webrtc is providing the standard WebRTC APIs.

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?

markandrus avatar Sep 28 '20 19:09 markandrus

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.

mrbar42 avatar Jun 16 '21 20:06 mrbar42

@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?

ghost avatar Jul 27 '21 20:07 ghost

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.

mwolfeu avatar Sep 18 '23 12:09 mwolfeu