简体   繁体   English

GCM-检测设备的周期性

[英]GCM - Detect Device Prescence

Is there a way to notify the server when a device connects and disconnects from the GCM platform? 当设备与GCM平台连接或断开连接时,是否有方法通知服务器?

Connection can be implemented easily enough at the application level since I would be able to send a message to my server via CCS. 在应用程序级别可以很容易地实现连接,因为我可以通过CCS向服务器发送消息。 Detecting when the device is offline does not appear to be so simple. 检测设备何时离线似乎并不那么简单。

I was hoping that there was a control message I could tap into to detect this? 我希望能收到一条控制消息以检测到此消息?

thenIn these types of scenarios's, the pinging methodology is the best. 那么在这些类型的场景中,ping方法是最好的。 For example if your client suddenly looses all his batterypower and the phone suddenly dies. 例如,如果您的客户突然失去了所有电池电量,而手机突然坏了。 The client will therefore not be able to send a request to your server that he is no longer online. 因此,客户端将无法向您的服务器发送不再在线的请求。 Simultaneously, on the server-side, he is still flagged as "online". 同时,在服务器端,他仍然被标记为“在线”。

The pinging mechanism reduces this problem by proposing a solution such that "If a ping is not received in a timely manner then flag the user as offline". ping机制通过提出一种解决方案来减少此问题,例如“如果未及时收到ping,则将用户标记为脱机”。

The Openfire plugin at the server side is one of the best one available till now that does this job for you. 到目前为止,服务器端的Openfire插件是目前为止最好的插件之一,可以为您完成这项工作。 You can give it a shot. 您可以试一试。

Hope that Helps!! 希望对您有所帮助!

有一个名册标志表明:

 connectionConfiguration.setRosterLoadedAtLogin(true);

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

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