Handling Delays in Users Connecting to Channels

6 views
Skip to first unread message

B. Shaibu

unread,
Aug 1, 2011, 6:26:34 AM8/1/11
to Juggernaut 2
Hi all,

I was hoping I could get some advice on how to track when users have
successfully subscribed and connected to a channel [socket.connected =
true]. I am working on a one-on-one chat app and have had problems
with messages being published before both users have successfully
subscribed. I want to add some sort of if statement that will delay
any messages until both users have their Juggernauts fully functional.

Is their some way I can track this? I looked at the Juggernaut
Observer, but I wasn't sure if that would apply for checking the
socket connections on multiple Juggernauts.

Best,

Ben

nca...@gmail.com

unread,
Aug 1, 2011, 3:37:00 PM8/1/11
to Juggernaut 2
Well the whole asynchronous nature of this setup is to deliver
messages to clients in this effectively realtime nature. Messages
won't be delivered to clients who are not connected. You can
manufacturer this window you're talking about on the server side of
things. I would suggest (using rails as an example), implementing a
queue that has a TTL for messages. You basically set up listeners for
the on subscribe event where messages are automatically served to
connecting clients if they are within that TTL.

I suppose you could mess with this on the client side, to delay
messages if they are the only people in a room. However, the right way
it seems is to associate something on the server side this this is
application specific logic and not logic pertaining to the socket
connection.

B. Shaibu

unread,
Aug 4, 2011, 10:10:14 AM8/4/11
to Juggernaut 2
Thank you for the feedback, I ended up going more along the client
route and changing the nature of when messages can be sent.
Reply all
Reply to author
Forward
0 new messages