Instant Messenger

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Instant Messenger

Post by kkonline »

I am in a process of making an instant messenger something similar to gtalk.

Till now i have registered the user and using session info i know if the user is logged or not. When he is logged on i update the database table field online =1 and otherwise it is 0 .(1 represents (s)he is online). It's fine till here... But next I have to check after 2 seconds if the user is still logged on or has logged out.

Suppose he is currently logged then the db field says 1, now he logs out but then also the db field says 1 although it should say 0 (as user logged out). SAo my problem is how to know if the user is still logged on or not.

If there something like pinging that can be done ... it could be helpful but wiill take alot of resources...

suggestion/comments/links welcome
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Surely if the user clicks a buttong or link to log out you could set the "online" field to 0.

Alternatively you could destroy their session and do some access session checking i.e. if(isset($session_var']))...
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I would definitely use a library for this.

Get familiar with the XMPP spec. There are a bunch of libraries, clients and servers for it already, and it's just plain awesome. Don't worry - there's still a mountain of work for you to do.

Also don't forget that HTTP is stateless, whereas chat/presence is stateful. You'll need the translation to happen somewhere, hopefully in a pre-built library!
Post Reply