instant messaging

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
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

instant messaging

Post by shawngoldw »

I'm planning on incorporating an instant messaging service into a website I'm building. I want to build this feature from scratch though, not use any already made scripts. I'm looking for any advice on how to go about this.

Here's what I'm thinking:

Set up a table in the database which stores messages
Using ajax check for new messages every X seconds

I have some problems with this in the tradeoff between significant delays in message reception and the load on the server from pinging it too rapidly for new messages.


Does anybody have any tips or advice?

Thanks,
Shawn
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: instant messaging

Post by JakeJ »

If you're going to hold back messages even for a second, people are going to hate it. It sort of takes the 'instant' out of instant messaging.

Otherwise, check this out: http://www.ape-project.org/
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: instant messaging

Post by shawngoldw »

Thanks, I 100% agree with you. I would really like to do this without other libraries though. I wasn't sure where to start but something in that link led me to comet and reverse ajax. I'm looking for some info on those topics but if anyone knows of any good resources on those subjects, please let me know :D
User avatar
ColonelSandersLite
Forum Commoner
Posts: 35
Joined: Sun May 09, 2010 1:32 am

Re: instant messaging

Post by ColonelSandersLite »

This might be just me, but I think the best way to go about this would be using a serverside standalone application (maybe a service) written in a more traditional language (I would use C++ probably as that tends to be my goto language). I would then build the user web interface as a java applet probably. If I decided to store logs of messages, the server software would send the message to a mySQL database *after* it has been sent on to the recipient.

I'm sure there's maybe a dozen ways to go about this though, but this would be my way. This actually kinda sounds like a fun project to do though, if I had the time, I would be tempted to do it as well, just for grins.
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: instant messaging

Post by shawngoldw »

Oh yes, this will be fun!! :D

I don't have a problem using another language for processing, but would like to stay away from java for the client side. This will only be a small part of a MUCH larger application, and I need to keep it in html, and javascript.

I have read some suggestions to use ajax with long polling but that will be a computational disaster in php. I also like the idea of storing the messages after they have dispatched to the recipient, this is definitely a good idea which I just hadn't thought about.

Would C++ be a good language for long polling comet? or is there a better approach? How does facebook do it? :wink:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: instant messaging

Post by s.dot »

This can be achieved using php's socket functions
I've tried before, and got some cool results, but never brought it to the point where it was usable in a web site
Although a flash interface can be done to the php socket server
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply