Jump to content


Photo

Showing the list of online users when programming an online chat room...........


  • Please log in to reply
2 replies to this topic

#1 raza.shahzad

raza.shahzad
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 26 July 2006 - 12:02 AM

I started to work out an online chat room using PHP. the basic idea was to use PHP wity MySQl to provide the users with a good online web browser based chat experience. In doing so i caught myself up in a problem that i want to discuss with you guys.
Displaying the list of online users is not a big issue with PHP. The 'behind the scene' structure is like....
1. the user logs in to the website with his username and password. everything is as simple as it can be. and there can be many other ways for doing so. i will appreciate help in any direction.
2. the database contains a column that saves the status of the user say:
name=status
value=online or offline.
if the user is online the status is set to the same and for offline the status in the database is saved or changed/updated to offline.
as long as the user uses the website/chat his name appears to be online and as he/she clicks log off, his status is set back to offline. and so on.
the problem comes when the user disconnects without clicking the log off link. in this case i am unable to set the database entry of status to offline because the user leaves the chat, turns off his browser or shuts down his PC without clicking the log off button due to which the process remains incomplete and other users who are online see the person to be online too.
Simply speaking, i want to know a better way to implement to my chat website. i wish the solution be like yahoo or msn messengers. whenever a user logs off or shuts down his PC accidently, the other user recieves a message that MR.XYZ has logged off.
Is there any solution to this problem. definitely there are many. the one i am thinking of is to place a field in the database that stores the time the last msg was recieved from the user and if the time extends a particular period, say 15minutes, the script considers the user to be offline. but this one is not the same as i want it to be like yahoo messengers'.

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 26 July 2006 - 12:10 AM

This is a problem many chatrooms have. One solution might be to open the chatroom in a new browser window, and detect when the window is closed with javascript, which can call a php script to log the user out.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 lil_missy

lil_missy
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 16 September 2006 - 10:19 PM

I started to work out an online chat room using PHP. the basic idea was to use PHP wity MySQl to provide the users with a good online web browser based chat experience. In doing so i caught myself up in a problem that i want to discuss with you guys.
Displaying the list of online users is not a big issue with PHP. The 'behind the scene' structure is like....
1. the user logs in to the website with his username and password. everything is as simple as it can be. and there can be many other ways for doing so. i will appreciate help in any direction.
2. the database contains a column that saves the status of the user say:
name=status
value=online or offline.
if the user is online the status is set to the same and for offline the status in the database is saved or changed/updated to offline.
as long as the user uses the website/chat his name appears to be online and as he/she clicks log off, his status is set back to offline. and so on.
the problem comes when the user disconnects without clicking the log off link. in this case i am unable to set the database entry of status to offline because the user leaves the chat, turns off his browser or shuts down his PC without clicking the log off button due to which the process remains incomplete and other users who are online see the person to be online too.
Simply speaking, i want to know a better way to implement to my chat website. i wish the solution be like yahoo or msn messengers. whenever a user logs off or shuts down his PC accidently, the other user recieves a message that MR.XYZ has logged off.
Is there any solution to this problem. definitely there are many. the one i am thinking of is to place a field in the database that stores the time the last msg was recieved from the user and if the time extends a particular period, say 15minutes, the script considers the user to be offline. but this one is not the same as i want it to be like yahoo messengers'.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users