Description
Hi.
Let me just start by saying that there is a possibility I misunderstood multiplex
operator completely. If that is so, sorry for spamming (and I would be super thankful for some resources on the subject).
As far as I understand, multiplex
simulates having websocket connections to multpile endpoints, while it really has only single connection to a "gateway" endpoint that can forward messages incoming from endpoints we pretend we have connection to. For example we pretend we have a connection per conversation in a chat app, while in fact there is only one connection to a server that marks incoming messages with flag that forwards a message to proper Observable.
If I get it right, then the question is, why we have a possibility to simulate such a connection only in one way (server -> client messages only)? Since multiplex returns an Observable, we do not have a possibility to next
message directly to fake socket that represents single conversation in my chat app. I have to use origin WebSocketSubject and while calling next
on it, every time manually mark my message with a flag that forwards my message to proper conversation.
In fact, we could take it much further and make multiplex
return WebSocketSubject, so that it could be itself multiplexed recursively again and again. In complex chat app with tree-like threads, conversations and user structure, I could represent such structure with my WebSocketSubjects and always forward messages directly where I want, without any boilerplate.
Also quite interestingly if done right, it would not be a breaking change at all.
Thoughts?