Vb - Count users on page

Hey guys,

Im creating a forum in vb (visual studio) and want to know how i can get no of users on the page.

I know you can use Membership.GetNumberOfUsersOnline() to get users online but i want to find how many are viewing a page.
runnerjp2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
This can be quite tricky. How do you know when someone is still on the page? Someone might have visited the page and immediately closed their browser... how will you know that they are no longer on the page? Or if they navigate onto another page... how will you know?

One mechanism you can consider is to generate a serial number (maybe using a GUID string), then have a Javascript that polls the server every few seconds (say every 3 seconds) and all that it does is to send back that same GUID to the server. On the server, you can perhaps have a DataTable in which you store the GUID and the last time you "heard" from that GUID... You can regularly clear out (from the datatable) any GUID values that havent "spoken" to the server in say 10 seconds... A count of the number of rows in that DataTable then becomes the number of people still on the page (relatively accurate within the last 4-6 seconds). It is very imprecise, but might do the trick...

This mechanism is also not without problems, for the number of connections that it opens and closes every so often with the server. Have a look at this (for other technical considerations) http://query7.com/avoiding-long-polling

The jQuery snippet below polls the server every 3 seconds for new information and displays it in a simple alert box.

function callComplete(response) {
	alert("Response received is: "+response);
};

function connect() {
	// when the call completes, callComplete() will be called along with
	// the response returned
	$.post('/path/to/script.php', {}, callComplete, 'json');
};

$(document).ready( function() {
	setInterval(connect,3000);
}

Open in new window

0
runnerjp2005Author Commented:
Sounds like a very coplex way about it... as u see on my other question i have been able to record views and delete them on other pages but the whole browser closing is the issue.

It must be done as i have seen it used in other places and i know php can do it very well
0
runnerjp2005Author Commented:
my other option is on every page to record the page the user visited last and at what time... then run a query of the page from the last 10 seconds and make anote of that
0
MlandaTCommented:
"my other option is on every page to record the page the user visited last and at what time... then run a query of the page from the last 10 seconds and make anote of that"

Does not help you to deal with browser window/tab closing. If you relaly want to be nearly accurate... you will need to have a way for the page to tell you applicaiton that "hey... I am still here dude.. dont count me out just yet!!!"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.