Google Groups Home
Help | Sign in
How to know wich users are connected ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Benjamin  
View profile
 More options Jul 22, 5:27 am
From: Benjamin <benjamin.vi...@hamburware.com>
Date: Tue, 22 Jul 2008 02:27:05 -0700 (PDT)
Local: Tues, Jul 22 2008 5:27 am
Subject: How to know wich users are connected ?
Hello,

I'm trying to setup a feature on my site that allows users to know
wich users are connected (using a picto green light/red light).

Is there a "good way" to do this ? Is there a symfony feature that can
help me ?

Actually, I've succeeded by coding a function ping() placed in every
actions.class preExecute().
But that seems pretty heavy to update a field "last_ping" in my users
table at every requests...

Thank you !

Benjamin


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Perriault  
View profile
 More options Jul 23, 3:52 am
From: "Nicolas Perriault" <nperria...@gmail.com>
Date: Wed, 23 Jul 2008 09:52:57 +0200
Local: Wed, Jul 23 2008 3:52 am
Subject: Re: [symfony-users] How to know wich users are connected ?
On Tue, Jul 22, 2008 at 11:27 AM, Benjamin

<benjamin.vi...@hamburware.com> wrote:
> Is there a "good way" to do this ? Is there a symfony feature that can
> help me ?

Something less accurate but performance-proof is to update a
last_connected_at column in your user model at authentication time,
then you can test for each user if his connection time is less than a
configureable amount of time (eg. 5 minutes)

HTH

++

--
Nicolas Perriault
http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
Phone: +33 660 92 08 67


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin  
View profile
 More options Jul 23, 9:04 am
From: Benjamin <benjamin.vi...@hamburware.com>
Date: Wed, 23 Jul 2008 06:04:43 -0700 (PDT)
Local: Wed, Jul 23 2008 9:04 am
Subject: Re: How to know wich users are connected ?
Thank you for the response.

The problem with this solution is that if the user is connected since
more than 5 minutes he will be considered offline.
And if I set something like 20 minutes it won't proof that the user is
online...

Is it possible to put a piece of code (maybe javascript ?) somewhere
to refresh the last_ping DB field every X minutes ?

thank you !

On Jul 23, 9:52 am, "Nicolas Perriault" <nperria...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eno  
View profile
 More options Jul 23, 1:30 pm
From: Eno <symb...@gmail.com>
Date: Wed, 23 Jul 2008 10:30:09 -0700 (PDT)
Local: Wed, Jul 23 2008 1:30 pm
Subject: Re: How to know wich users are connected ?
On Jul 23, 9:04 am, Benjamin <benjamin.vi...@hamburware.com> wrote:

> Is it possible to put a piece of code (maybe javascript ?) somewhere
> to refresh the last_ping DB field every X minutes ?

Why do you need to do this? Sounds like a bad idea - imagine 1000
users all doing a GET just to update a field...

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan  
View profile
 More options Jul 23, 11:54 am
From: Jonathan <jhalter...@gmail.com>
Date: Wed, 23 Jul 2008 08:54:34 -0700 (PDT)
Local: Wed, Jul 23 2008 11:54 am
Subject: Re: How to know wich users are connected ?

> Is it possible to put a piece of code (maybe javascript ?) somewhere
> to refresh the last_ping DB field every X minutes ?

Yes, you could certainly do that and just have an ajax POST request
update the value every 5 minutes or so. You'd have to use a javascript
timer to fire off the request after some timeout has been achieved and
recalculate that timeout value after each request.

Another good approach you could take is to use memcache to store this
information, as opposed to putting it in the database. Memcache (if
you're not familiar with it) essentially runs as a daemon on the
server, similar to a database server, except that it allows you to
persist data in the server's memory, so read and write operations are
VERY fast. This could be a good thing to utilize for tracking whether
or not a user is online as opposed to writing to the database for each
request... plus memcache is good to use for caching data and other
stuff.

jonathan

On Jul 23, 6:04 am, Benjamin <benjamin.vi...@hamburware.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Perriault  
View profile
 More options Jul 23, 3:54 pm
From: "Nicolas Perriault" <nperria...@gmail.com>
Date: Wed, 23 Jul 2008 21:54:29 +0200
Local: Wed, Jul 23 2008 3:54 pm
Subject: Re: [symfony-users] Re: How to know wich users are connected ?

On Wed, Jul 23, 2008 at 3:04 PM, Benjamin <benjamin.vi...@hamburware.com> wrote:
> The problem with this solution is that if the user is connected since
> more than 5 minutes he will be considered offline.
> And if I set something like 20 minutes it won't proof that the user is
> online...

You can update a "last_active_at" field on every action the user does,
or take advantage of a database session storage, adding this
"last_active_at" timestamp in the session table at writing time, then
you could poll it to see real users activity... But it can be very
heavy, I guess.

Maybe using memcache as suggested could solve your problem more efficiently...

++

--
Nicolas Perriault
http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
Phone: +33 660 92 08 67


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin  
View profile
 More options Jul 24, 4:29 am
From: Benjamin <benjamin.vi...@hamburware.com>
Date: Thu, 24 Jul 2008 01:29:45 -0700 (PDT)
Local: Thurs, Jul 24 2008 4:29 am
Subject: Re: How to know wich users are connected ?
Thank you for your responses.

I think I'm going to explore memcache, but it's the first time I hear
about it, so it might be a little difficult...

By the way, for the Ajax post solution, I really don't know where I
can put this piece of code. I thought about the layout but it is
refreshed at every request so the timer too...

On Jul 23, 9:54 pm, "Nicolas Perriault" <nperria...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
michael.piecko@googlemail .com  
View profile
 More options Jul 24, 7:12 am
From: "michael.pie...@googlemail.com" <michael.pie...@googlemail.com>
Date: Thu, 24 Jul 2008 04:12:42 -0700 (PDT)
Local: Thurs, Jul 24 2008 7:12 am
Subject: Re: How to know wich users are connected ?
I think the best solution is still to observe a last-update
(updated_at) field of a database session and to query all sessions in
the last 5 minutes, for example. This is still the best way IMO to
recognize a "real" user action, i mean, he is still there.

Imagine i leave my computer for lunch or something. A javascript
"heartbeat" will fail your question "Is this user still there?".

Michael

On Jul 24, 10:29 am, Benjamin <benjamin.vi...@hamburware.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin  
View profile
 More options Jul 24, 8:58 am
From: Benjamin <benjamin.vi...@hamburware.com>
Date: Thu, 24 Jul 2008 05:58:57 -0700 (PDT)
Local: Thurs, Jul 24 2008 8:58 am
Subject: Re: How to know wich users are connected ?

Michael's solution sounds great !  But I take the risk to be treated
as a noob : I don't know what is a database session...

I'm going to read some documentations, if you have any tips or a good
link don't hesitate ;-)

Thanks again !

On 24 juil, 13:12, "michael.pie...@googlemail.com"


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Perriault  
View profile
 More options Jul 24, 11:49 am
From: "Nicolas Perriault" <nperria...@gmail.com>
Date: Thu, 24 Jul 2008 17:49:33 +0200
Local: Thurs, Jul 24 2008 11:49 am
Subject: Re: [symfony-users] Re: How to know wich users are connected ?

On Thu, Jul 24, 2008 at 2:58 PM, Benjamin <benjamin.vi...@hamburware.com> wrote:
> Michael's solution sounds great !  But I take the risk to be treated
> as a noob : I don't know what is a database session...

> I'm going to read some documentations, if you have any tips or a good
> link don't hesitate ;-)

Start from here for session storage with symfony: http://tinyurl.com/6dufck :-)

++

--
Nicolas Perriault
http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
Phone: +33 660 92 08 67


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
michael.piecko@googlemail .com  
View profile
 More options Jul 24, 12:00 pm
From: "michael.pie...@googlemail.com" <michael.pie...@googlemail.com>
Date: Thu, 24 Jul 2008 09:00:05 -0700 (PDT)
Local: Thurs, Jul 24 2008 12:00 pm
Subject: Re: How to know wich users are connected ?
If you need some basic stuff on handling sessions with a database
(understanding), try google ("php database session"). There are some
great tutorials out there:
http://www.developertutorials.com/tutorials/php/saving-php-session-da...

And symfony has everything to start using them ...

Michael

On Jul 24, 5:49 pm, "Nicolas Perriault" <nperria...@gmail.com> wrote:


    Reply    Reply to author    Forward