Opening and closing socket connections on new page loads?

106 views
Skip to first unread message

baden

unread,
Mar 3, 2012, 9:50:53 AM3/3/12
to Socket.IO

I am going to build a notification system for events like user logged
in, etc. on a system, and want to ensure I've got this right.

A user logs in and I create a broadcast event for that - contains the
user ID.
Broadcast message gets sent out to all users connected to the system.
Only users who have a matching "friend" will receive a visual
notification on the client side.

This is build on a Microsoft stack , so for the architecture:
IISNode
Node.JS
Socket.IO

Does that sound about right?

One issue is that the live feed section is not maintained across page
loads. If there are a bunch of clients (a few thousand) doing new
page loads, is there significant enough overhead in re-establishing a
WebSocket connection (if available) to use a different method? Many
clients will not have WebSocket capabilities and Socket.IO's fallback
to XMPP will work fine in this case.


Thanks.

Daan Weddepohl

unread,
Mar 4, 2012, 2:41:31 PM3/4/12
to sock...@googlegroups.com, Socket.IO
If privacy/security is important this might not be a good idea. A user will be able to 'hack' his own client to display all users that come online.

Brian Gruber

unread,
Mar 4, 2012, 3:11:40 PM3/4/12
to sock...@googlegroups.com
Sounds like you really only want to send the User Online/Offline/etc to those people subscribed to that user. Maybe rooms would work?? How bout this?

1. When a user logs in to the system join them to all their "friend" rooms? 
2. Then broadcast an event to that particular user's room and all their "friends" will see it.
3. Broadcast whatever other messages to that room that you want.

Does that work?

- Brian
--
Regards,

Brian Gruber

Real time visitor analytics, chat, heatmaps & polls.

Baden

unread,
Mar 4, 2012, 3:19:57 PM3/4/12
to sock...@googlegroups.com
No. This will be a scrolling news feed section on a site. Trying to iron out the best strategy for this.

Granted, someone could try to hack their client but how is a normal push normally done? ie. Private msg in chat? Would this would kind of be the same concept or does the server decide which client gets the msg? If so how would I accomplish this?


Thanks.
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Mark Hahn

unread,
Mar 4, 2012, 3:27:17 PM3/4/12
to sock...@googlegroups.com
>  Would this would kind of be the same concept or does the server decide which client gets the msg? If so how would I accomplish this? 

I have this in my app.  The code in the browser decides what to show, but I have a user assigned to each connection in the server and I have special code only to check permissions.  So a hack could not get anything. 

BTW, hacks are really easy using Greasemonkey.

.

Baden d.

unread,
Mar 4, 2012, 11:27:53 PM3/4/12
to sock...@googlegroups.com
Yeah, that's the concept I was thinking of.  The client side contains a collection of users (friends) that they are allowed to get notifications from.  If a broadcast message comes through with the ID of one of their "friends" then they get an update.  

I'm over-simplifying "friends" here, as there are some more complicated rules that will define a successful recipient.

Anand George

unread,
Mar 5, 2012, 5:29:11 AM3/5/12
to sock...@googlegroups.com
Hi!

Have you checked out https://github.com/Fabryz/support-chat Seems to be a nice implementation.

Anand

Baden d.

unread,
Mar 5, 2012, 9:45:42 AM3/5/12
to sock...@googlegroups.com
Anand,

That looks like something I would want to implement later, however for now, I think that the solution Mark Hahn discussed is more along the lines of what I'm thinking.  In essence, this is like a "chat client" where we're sending JSON objects instead of just text.

Anand George

unread,
Mar 5, 2012, 9:56:41 AM3/5/12
to sock...@googlegroups.com
That's nice. Any updates on implementation would be welcome.

umar farooq

unread,
Mar 5, 2012, 4:33:08 PM3/5/12
to sock...@googlegroups.com
Dear Anand George,
                             I want server side implementation in JAVA EE. can you provide such a thing in which client side is javascript based and server side JAVA EE based... Please help me if you can...
--
Best Regards,
Umar

Anand George

unread,
Mar 7, 2012, 12:20:56 AM3/7/12
to sock...@googlegroups.com
Sorry Umar... only Node.js for me :(
Reply all
Reply to author
Forward
0 new messages