instant messaging with php
Posted 24 August 2006 - 07:38 PM
Well yes I think it will be quite hard and a couple of articles I had read about it convinced me that the idea was sucks But none of them had implemented XMLHttpRequest object in them. So that's where the idea becomes more intresting of course.
I would like to discuss it with you about it. How can we make it, if we can how it will be it's perfomance.
Some things that comes to my mind XMLHttpRequest (I will call it ro after this) will check every 30 seconds if there is a new message or not. If there is, a pop-up window or something like that will show as a conversation is started, ro will start checking if there is a new message or not every 5 seconds. Here's the first problem what if there is 3 conversation is going on. The whole thing collapses because only 2 connection allowed at a time. Well a possible solution will be to send conversation id's with ro and then get messages of that conversation according to the id and with one connection we are done with that too.
So we go on with message posting. How the heck we can do it. Yeah the user will write it's message and then press the submit. So as he press post button, we disable entring anymore entries and disable post button. We send the data via ro and then enter it to the db then we return the new messages and then add to the messaging log of the im window. And the 5 second is reset.
Well here comes another problem, what will happen if the conversation is ended. Everything is cool if he click on the cross, kill the conversation id and no more check about that. What if it becomes to a timeout, if he does not click on that cross. After a couple of trying which does not return any new messages I can suspend the conversation id and then return that id to the 30sec check. And everything can be cool from there.b When a new messeage is returned from ro after 30 sec we then return to the 5 sec loop. A problem can occur if one clicks on the cross and one doesn't. One's conversation id is killed and the other's is suspended. But as the other's id is killed there is no way that suspended id can take anymore responses. So there will be lot's of im windows in the browser which belongs to the conversation with the same person. So I also just add the user ids. If the suspende conversation id's user ids (the one that talk and the one that reads) match with the new new message then add the new message to the message log then put the conversation id in the 5 sec loop again.
This are possible things that can happen and possible solutions I have found. I'm sure that I'm missing something. The JS code will be huge perhaps which will really be a problem, and it will require a good connection at the user side and a good server which will handle requests from lots of computer nearly every 10 sec or something.
I also welcome other solutions without php but via irc (which I think it will be easier for me but I'm not sure how I can protect it.) or java applets (msn web messenger wasa based on something like this I think.) or another thing that I do not know.
Any comment or idea is welcome.
Posted 25 August 2006 - 08:00 AM
Posted 25 August 2006 - 08:17 AM
Posted 25 August 2006 - 08:57 AM
But ajax is not much JS. There is only a XMLHTTPRequest Object and that's all. Total ajax js code is nearly 20 lines or something. And parsing the data you got is not that much if you use JSON or XML.
Posted 25 August 2006 - 10:13 AM
On the other hand, if you want to do it for the sake of having done it, then go ahead , It can't harm in learning how "AJAXY" stuff works so you can then use it in other projects in the future, just be aware that you're not doing anything that hasn't already been done
Posted 25 August 2006 - 10:58 AM
Posted 25 August 2006 - 12:23 PM
Sigh, yeah even the best idea that comes to your mind had already been thought by someone else and even realized (just like in this case:)). Yeah that's quite true . I have lost of my enthousiasme to make something that nobody has done years ago, aaaah, poor me
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users