如何向用户显示实时信息?

时间:2022-01-04 03:54:18

I need to show new comments to the user in real-time (similar to Youtube's live comments system but with no auto-adding).

我需要实时向用户显示新的评论(类似于Youtube的实时评论系统,但没有自动添加)。

Maybe I need to use pools with Asyn controller to handle requests and then show it if the user clicks on something like "show more 10 comments".

也许我需要使用与Asyn控制器的池来处理请求,然后在用户点击“显示更多10条评论”时显示它。

Or, for example, similar to *'s alert for new inbox messages.

或者,例如,类似于*对新收件箱消息的警告。

1 个解决方案

#1


3  

It looks like you're wanting to 'push' data to the user in real-time.

看起来你想要实时向用户推送数据。

Previously this might have been done with a bit of a 'hack' solution known as long-polling

在此之前,这可能是通过一种称为长轮询的“hack”解决方案实现的

With long polling, the client requests information from the server in a way similar to a normal polling; however, if the server does not have any information available for the client, then instead of sending an empty response, the server holds the request and waits for information to become available (or for a suitable timeout event), after which a complete response is finally sent to the client.

对于长轮询,客户端以类似于普通轮询的方式从服务器请求信息;但是,如果服务器没有任何客户端可用的信息,那么服务器将保存请求并等待信息可用(或者等待合适的超时事件),然后将完整的响应发送给客户端。

However you might want to look into the HTML5 world of WebSockets. To do this I'd recommend reading up on SignalR and following some tutorials (watch the pluralsight videos).

但是,您可能想要了解WebSockets的HTML5世界。为此,我建议在SignalR上阅读并遵循一些教程(请观看pluralsight视频)。

ASP.NET SignalR is a new library for ASP.NET developers that simplifies the process of adding real-time web functionality to your applications.

ASP。NET SignalR是ASP的一个新库。NET开发人员简化了向应用程序添加实时web功能的过程。

There is a lot of information already available on this topic.

关于这个话题已经有很多信息了。

#1


3  

It looks like you're wanting to 'push' data to the user in real-time.

看起来你想要实时向用户推送数据。

Previously this might have been done with a bit of a 'hack' solution known as long-polling

在此之前,这可能是通过一种称为长轮询的“hack”解决方案实现的

With long polling, the client requests information from the server in a way similar to a normal polling; however, if the server does not have any information available for the client, then instead of sending an empty response, the server holds the request and waits for information to become available (or for a suitable timeout event), after which a complete response is finally sent to the client.

对于长轮询,客户端以类似于普通轮询的方式从服务器请求信息;但是,如果服务器没有任何客户端可用的信息,那么服务器将保存请求并等待信息可用(或者等待合适的超时事件),然后将完整的响应发送给客户端。

However you might want to look into the HTML5 world of WebSockets. To do this I'd recommend reading up on SignalR and following some tutorials (watch the pluralsight videos).

但是,您可能想要了解WebSockets的HTML5世界。为此,我建议在SignalR上阅读并遵循一些教程(请观看pluralsight视频)。

ASP.NET SignalR is a new library for ASP.NET developers that simplifies the process of adding real-time web functionality to your applications.

ASP。NET SignalR是ASP的一个新库。NET开发人员简化了向应用程序添加实时web功能的过程。

There is a lot of information already available on this topic.

关于这个话题已经有很多信息了。