服务器可以不使用CallBack方法将消息传递给客户端。 [英] Can server pass message to client without using CallBack Method.

查看:63
本文介绍了服务器可以不使用CallBack方法将消息传递给客户端。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



问题有些不在乎,但仍想了解更多信息。



我有一个场景,我希望在服务器现在关闭时向所有客户端发送通知。

当我再次启动服务器时,我想在关机之前向所有在线客户发送通知。





我不知道它是否可能很容易或有一些解决方法....





谢谢,

Hello Everyone,

Question is bit out of mind but still would like to know more about it.

I have a scenario where i want to send notification to all clients when Server is shutting now.
and when i again server starts, i want to send notification to all clients that were online before shutting down.


I don't know if its possible easily or there is some workaround....


Thanks,

推荐答案

这是可能的。您可能听说过服务器推送。这是服务器在没有客户端请求的情况下将资源推送到客户端的方式。在您的方案中,只要客户端与服务器连接,就可以通过注册客户端的IP来轻松完成;当服务器关闭时,只需向客户端发送关于关闭的通知;当服务器恢复时,你需要确保客户端仍然存在(我不知道你如何确定它),如果客户端还活着,你可以再次发送服务器的通知活。如果客户端在服务器处于活动状态且未关闭时脱机,则必须取消注册客户端的IP。为此你需要寻找一些最好的方法,否则你会继续发送通知,可能是一些错误的IP。
This is possible. You may have heard about server-push. It is a way in which a server pushes resources to the clients without the request of clients. In your scenario, you can do it easily by registering the IP of the client whenever a client is connecting with the server; when the server is shutting down, just send a notification to the client about the shut down; and when the server is back, you need to make sure the client is still alive or not (I don't know how you can make sure about it) and if the client is alive you can send it the notification again that the server is alive. You will have to de-register the IP of the client in case client has gone offline while server was alive and not shut down. And for that you need to look for some best possible way otherwise you will keep sending notifications to, may be, some wrong IPs.


这篇关于服务器可以不使用CallBack方法将消息传递给客户端。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆