coast-team / netflux

JavaScript client and server side transport API based on WebRTC & WebSocket
https://coast-team.github.io/netflux
GNU Affero General Public License v3.0
213 stars 14 forks source link

Why is Facade.onPeerJoining() not a function of Network ? #8

Closed cjdelisle closed 8 years ago

cjdelisle commented 8 years ago

Since onPeerJoining() passes the Network to which the peer has joined, I would like to know why the function is not a function of Network ?

cjdelisle commented 8 years ago

Same question applies for Facade.sendJoinRequest(Peer[], Network).

cjdelisle commented 8 years ago

Same question applies to Facade.onBroadcastMessage() :)

kalitine commented 8 years ago

We were thinking about this. If we were in place of a developer who might be using this API, would he prefer to specify the same action when a new peer joins some network or would he prefer for each network specify different actions?

From document editing point of view we thought that the first case is more appropriated. In other words, the fact that a NEW PEER HAS JOINED a network is more important that in THE NETWORK a new peer has arrived. For this reason we made this choice.

The same thoughts about Facade.onBroadcastMessage().

And concerning Facade.sendJoinRequest(Peer[], Network). To me, it seems logical to have this method in Network (I do not remember why we put it in Facade instead :)) and I see nothing against this change to the API.

cjdelisle commented 8 years ago

I would plan to use only one global Facade (for memory savings) and create networks for each document, chat and other realtime element (including in different tabs of the browser) so I will plan for significant code which never sees the Facade and is only passed in a Network object when it is created.