gpt4 book ai didi

java - java中如何向客户端广播数据

转载 作者:太空宇宙 更新时间:2023-11-04 14:21:09 24 4
gpt4 key购买 nike

我正在编写一个小型桌面应用程序,用于向正在使用此应用程序的客户端显示通知。因此我的应用程序应该从存储所有通知的服务器获取通知。因此,如果有 100 个客户端使用此应用程序并且如果我向服务器添加一些通知,我如何将这些数据发送给 100 个客户端...请告诉我一些我可以使用哪些 API 或哪些技术来实现此功能。此应用程序是一个桌面应用程序

最佳答案

很简单...

1) Make Arraylist of socket that has socket of all clients. // i.e when new client connected then add its socket into th ArrayList.
2) When ever there is any update just iterate through the ArralyList and send notification to all the connected clients.

关于java - java中如何向客户端广播数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27175945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com