muaz-khan / WebRTC-Scalable-Broadcast

This module simply initializes socket.io and configures it in a way that single broadcast can be relayed over unlimited users without any bandwidth/CPU usage issues. Everything happens peer-to-peer!
https://rtcmulticonnection.herokuapp.com/demos/Scalable-Broadcast.html
532 stars 142 forks source link

How server works #6

Open oviniciuslara opened 9 years ago

oviniciuslara commented 9 years ago

I would like someone to explain to me how the server works? I want to rewrite it in PHP because it does not know anything about nodejs ..

muaz-khan commented 8 years ago
  1. Give each user a userid or unique-token
  2. Categorize users:
    1. First user should be broadcaster
    2. Second should be receiver (at the moment) until server wanna makes him a relayer
    3. Server can make any user as a relayingPeer based on its capabilities
  3. (Assume that) a broadcaster is a relaying-peer as well.
  4. When a new user enters in the room, lookup for available relayingPeer, and return available peer's token/userid to the newcomer.

To conclude it:

  1. First user => broadcaster+relayer

    First user NEVER receives.

  2. Second user => receiver (possible relayer as well)

    Second user directly receives from broadcaster.

  3. Third user => receiver (possible relayer as well)

    Third user can receive either from broadcaster or second user.