简体   繁体   中英

How can I create a chat communication channel between 2 users in asp.net

I want to add a chat application in my website. I have developed almost part of chat application.But I am getting problem to create chat communication channel.I an using Web-Service to insert and retrieve messages from data base. When I enter the new message then another user can not read that message until he will reload its chat window.

I'm not totally sure what your question is - however:

If you want to create a chat app in .Net why not look into SignalR?

https://github.com/SignalR/SignalR/

They have a demo that shows (In a short amount of code) how to write a chat application.

http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx

There is a live chat app written using SignalR also - http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx

If you are really up to creating you own chat app. Then here is some idea on how you can make it work based on your current progress.

  • Create an instance_id for your chat messages, this will determine who are able to access these messages. if two people are chatting together, they should have the same instance_id, aside from the sender and receiver ids.
  • You have to use an Ajax Timer to constantly get update on new messages.

    Are you in someway imitating facebook chat?

    first try the chat using web pages for easier implementation then work your way up on making it a widget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM