简体   繁体   English

通知所有客户有关更改

[英]Notify all clients about a change

so I'm in a little project of mine and for now the client gets some information it needs using requests, more precisely requesting the data to a nodejs server running express.所以我在我的一个小项目中,现在客户端使用请求获取它需要的一些信息,更精确地请求数据到运行 express 的 nodejs 服务器。 The thing is I want that when 1 client alters something every connected client gets a notification that something just changed.问题是我希望当 1 个客户端更改某些内容时,每个连接的客户端都会收到一个通知,表明某些内容刚刚更改。 How could I do this?我怎么能这样做? I'm new to all this networking stuff so any help is appreciated.我对所有这些网络东西都很陌生,因此感谢您提供任何帮助。 Also the client is a C# Windows Forms客户也是 C# Windows Forms

This sounds like it can be achieved via the publisher-subscriber design pattern.这听起来可以通过发布者-订阅者设计模式来实现。 Where each client will subscribe to an event and listen to it (perform an action on it) whenever there's an event being broadcasted.每当有事件被广播时,每个客户端都将订阅一个事件并收听它(对其执行操作)。 I suggest you take a look atthe pattern and see how others have implemented it particularly to your situation.我建议你看看这个模式,看看其他人是如何根据你的情况实施它的。

You can take a look at Socket.io which is "a library that enables real-time, bidirectional and event-based communication between the browser and the server."您可以查看Socket.io ,它是“一个能够在浏览器和服务器之间实现实时、双向和基于事件的通信的库”。

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

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