简体   繁体   English

如何在asp.net中的2个用户之间创建聊天通讯渠道

[英]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. 我已经开发了聊天应用程序的几乎一部分。但是在创建聊天通信通道时遇到了问题。我使用Web服务从数据库中插入和检索消息。 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? 如果要在.Net中创建聊天应用程序,为什么不考虑SignalR?

https://github.com/SignalR/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 http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx

There is a live chat app written using SignalR also - http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx 还有一个使用SignalR编写的实时聊天应用-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. 为您的聊天消息创建一个instance_id,这将确定谁可以访问这些消息。 if two people are chatting together, they should have the same instance_id, aside from the sender and receiver ids. 如果两个人在一起聊天,则除了发送者和接收者ID外,他们应该具有相同的instance_id。
  • You have to use an Ajax Timer to constantly get update on new messages. 您必须使用Ajax计时器来不断获取新消息的更新。

    Are you in someway imitating facebook chat? 您是否正在模仿Facebook聊天?

    first try the chat using web pages for easier implementation then work your way up on making it a widget. 首先尝试使用网页进行聊天以简化实现,然后逐步将其制作为小部件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何创建动态页面? Javascript还是ASP.NET? - How can I create dynamic pages? Javascript or ASP.NET? 在asp.net中聊天应用程序 - chat application in asp.net javascript与asp.net通信 - javascript to asp.net communication 如何在asp.net中创建带有动态控件的页面? 如何定义控件集合? - How to create a page with dynamic controls in asp.net? How can I define a control collection? ASP.Net-使用表单身份验证时,如何允许未经身份验证的用户查看导入的脚本文件? - ASP.Net - How can I allow imported script files be viewed by unauthenticated users when using Forms Authentication? 如何使用Java脚本从asp.net中的用户输入中获得两天之间的日期差 - How to get the difference between two dates in days from users input in asp.net using Java script 如何使用asp.net创建响应表? - how do I create a responsive table using asp.net? 在多频道聊天应用程序中,如何显示仅与特定聊天频道有关的消息? - In a multichannel chat application how can I display messages pertaining only to a specific chat channel? 如何仅使用严格的javascript / jquery / ajax(不使用node.js / socket.io)在仅2个用户之间创建网络聊天 - How do I create a web chat between only 2 users using strictly javascript/jquery/ajax(No node.js/socket.io) 我如何创建文本框,可以使用Asp.net mvc4中的jquery ajax在数据库中保存任何输入 - how can i create textbox which can save any input in database using jquery ajax in Asp.net mvc4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM