Finding first connected client in Channels

How can I find if the incoming messages is from the first connected client and move further?

Let’s say if topic 123 has 10 connected clients. How to find if the incoming message is from the first client who connected to the current topic and move further with the business logic?

Hi @mcnaveen I think it’ll help to understand what you want to do when the “first” client connects. In some sense this isn’t knowable, nor is it quite the right way to think about topics. A topic isn’t a singular thing.

Suppose you have two servers. Client A connects to server X on topic 123 and Client B connects to server Y also with topic 123. Which is first? This isn’t really knowable. If they’re close enough in time it isn’t meaningful to speak about first universally.

You could use a database to store topics and do some sort of find or create on mount, which would give you a definition of first as “The first time a row in a database gets created”. It just depends on what you’re trying to do.


Ah interesting.

Here is my use case.

I’m doing some experiment with the browser scrolling via web socket. Confused about the implementation.

Let’s take Browser 1, connects to server A with the topic 123 and with js it scrolls upto 60% automatically and the Browser 1 pushes the scroll position to the websocket server.

Now the browser 2 connects to server A with the same topic 123 and it’ll be stuck at 0% scroll. Instead I want to auto scroll upto 60% or so which is already shared by Browser 1 and continue to do so.