Chat Application in ASP.NET

泄露秘密 提交于 2019-12-06 10:36:58

Best thing you can do is use a Persistent HTTP Connection. The way google does with Google Talk on their GMAIL website.

Remember that HTTP is a stateless protocol and that each transaction is made from the client to the server.

The server can use sessions to determine if this client is "known" but as for sending information back to the client using plain old HTTP I think that is impossible (I mean from a server initiated connection, not a response to the client)

You would need to use Javascript to poll the server for information.

If you want it the other way around, you could possibly use Java or Flash but then you also need to think about NAT tunneling, proxy servers and any other weird setups that the clients could be using.

No. I don't think the server can send message to client's browser. Here is how I implement chat application:

  1. client1 post message via Ajax to server
  2. server save it to repository (I'm using singleton object for this case)
  3. client2 get the message from repository
  4. mark the message as read

I will save chat logs to database once the chat session closed or expired.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!