Page 1 of 1

instant messaging

Posted: Thu Aug 05, 2010 12:07 pm
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

Re: instant messaging

Posted: Thu Aug 05, 2010 3:14 pm
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/

Re: instant messaging

Posted: Thu Aug 05, 2010 3:25 pm
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

Re: instant messaging

Posted: Thu Aug 05, 2010 3:52 pm
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.

Re: instant messaging

Posted: Thu Aug 05, 2010 10:18 pm
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:

Re: instant messaging

Posted: Thu Aug 05, 2010 10:34 pm
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