简体   繁体   English

Android:开发聊天应用

[英]Android: Developing a Chat app

I am developing an one-to-one chat app. 我正在开发一对一的聊天应用程序。 The problem is how should I keep all clients and server in sync? 问题是如何使所有客户端和服务器保持同步? There can be multiple cases when the message fails to send from the client, or it is not received by the client. 在多种情况下,邮件无法从客户端发送或客户端未收到。

Right now, I am using a pub sub service and GCM. 现在,我正在使用pub sub服务和GCM。 Whenever user is using the app, I subscribe to a unique channel to receive messages and use api to send message. 每当用户使用该应用程序时,我都会订阅一个唯一的频道来接收消息,并使用api发送消息。 Also, through pubsub I am maintaining user online status. 另外,我通过pubsub维护用户的在线状态。

Whenever app goes into background, pubsub disconnects and user goes offline. 每当应用进入后台时,pubsub就会断开连接,并且用户会脱机。 In this case GCM is used to deliver messages to the client. 在这种情况下,GCM用于将消息传递到客户端。

This systems is working fine. 该系统运行良好。 But rarely there are messages that are not delivered to the client. 但是很少有没有传递给客户端的消息。

Can this be improved to assure message delivery ? 是否可以改进此方法以确保消息传递?

Here is a good tutorial. 是一个很好的教程。 with client side and server side codes... 带有客户端和服务器端代码...

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

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