• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Basic Chat application on web with Ajax

Hi all,

I want to add a simple chat functionality between online user on my site. I use c# at server side. I currently hold online user list on a table in db and show who is online on the page. I update this list every two minutes by Ajax. I wrote a easy to use ajax javascript code. Here I want to learn How to make messaging between two online users.

The first thing that come in to mind is
on page, check for current user has new message by ajax with a interval one second. And pass his/or her message to server with a send message function.  But this makes really so many request as the online user numbers grow up. And it also will harm explorer at client side as if he/or she talk to many users.  

Is there any other possible methods to send message from server to client without a request taken. Or simple how goggle make chat from gmail page. I like smthg like that. I do not want to use or copy a know code to my project. So do not refer any open source project, only tell me about methods that could be available and give explanatory code examples.

  • 2
1 Solution
ZvonkoSystems architectCommented:
The polling for updates does not mean that you request for the complete last state message and compare on client side. The better strategy is to get together with the state also some kind of state stamp, for example milisecond time stamp. So at next second polling you ask only wether that time stamp changed. If that change occur then you can ask for complette message text. The stamp request are only few bytes every second.

To see how google mail is doing that polling you can look at the message flow by using http://www.fiddlertool.com

karanbaAuthor Commented:
I try fiddlertool but nothing seems on action
ZvonkoSystems architectCommented:
Did you install Fiddler2?
For https like gmail you need Fiddler2.
Then you will see the polling in the fiddler window.

Hi Zvonko, I am sure your solution helped Karanba and now I am in the exact situation and trying to come with my own chat system between all the users currently online on my application.

I would appreciate if you can guide me how to go about it and get it accomplished. I dont have a messaging system in place as of now and am wondering how to start the communication between the users though I can see the online users.

Please help.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now