Sunday, August 2, 2009

How to design and code a chat program with asp.net?

I have found quite a number of chat program samples but the problem is that when i dwnload the sample code, i can't really view the code and designs at the same time making it hard to understand how it is done...does anyone here know how to code a simple multi chat program using asp.net?? care to help me?? please

How to design and code a chat program with asp.net?
Chat programs are one of the easiest .. so don't worry! You can store your chat inside a database or a plain text file. I assume that yours is a web-based application. So just split the page up into 2 frames, one frame displaying the contents of the database or the text file, while the other is a form that stores the typed sentence inside the database or text file. A more complex one can be created with the help of AJAX (Asynchronous Javascript And XML). If you need more detailed help, drop me an email.
Reply:Quite some time back, I had used the following technique for simulating chat on ASP:


1. Create application level variables to hold current chat lines (from 10 to 15 or 20 - depending on how many lines you want to show)


2. When a user logs in, in Session_Start events, add his entry into the last line variable. Before this, you need to move lines up - i.e. line 2 to line 1, line 3 to line 2, line 4 to line 3 etc. This can be done easily in a loop.


3. Design a page with two frames: top frame showing chat content, second frame showing a text box with submit button.


4. When user clicks on submit at second frame, on server script, take the submitted text, add it to the last line variable along with user name. Move all previous lines one up - as described above.


5. When user exits, use Session_End event to announce his departure in similar way.





Hope this helps. I am sorry - I could not provide code. Its quite long time (more than 4 years) since I have used the above logic and doesnt have that code now.





Good luck.

pollen

No comments:

Post a Comment