16

我正在浏览whatsapp应用程序,我注意到它第一次从服务器获取缩略图,将它们保存在缓存中,然后它从缓存而不是服务器中获取这些缩略图。(如位图延迟加载)。

到目前为止,我已经完成了位图延迟加载部分的实现。

但是我有一个问题如下:

当任何联系人更改其个人资料图片时,用户的 whatsapp 应用程序如何检测到该特定更改以及它如何仅更新该特定缩略图,导致应用程序应该从缓存中获取缩略图。

我对此一无所知。任何帮助表示赞赏。

编辑:

它是否使用推送通知来通知客户端应用程序更新相应的配置文件缩略图?

4

2 回答 2

11

来源: WhatsApp建立在C2DMXMMP 之上,用于消息传递。MQTT是另一种用于最小化电池使用的协议。

When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory

Answering your question: So WhatsApp may be using XMMP push or a GCM push notification(C2DM is deprecated ;] ) to inform all the client that some event has occurred and all it's client needs to take care of the same. In your case event is to update your profile pic in devices of your friends in WhatsApp contacts

In your case, you can use GCM to update clients regarding such events. I don't have much idea about XMPP but You can also have a look at Smack API(An Open Source XMPP (Jabber) client library for instant messaging and presence) and this interesting post

I hope I answered your question. Good Luck :)

Edit:

GCM is a service from Google that uses a persistent XMPP connection to communicate with Android devices. You can use any of the following techniques of GCM to achieve this.

于 2013-08-30T12:20:50.397 回答
2

处理这种情况的一种简单方法是modified datetime在存储图像和缩略图路径的表中保留一个。您必须保留图像的 url 以及修改日期作为参数。

例如:

http://yourdomain.com/images/user_id.png?q=modifieddatetime

每当应用程序尝试打开此链接时,它会首先检查它是否在缓存中可用。如果不是,则将从服务器获取新图像。

我还没有在 Android 上尝试过这个,但它应该可以工作。我通常在我的网络应用程序中这样做。

于 2013-08-20T08:54:46.190 回答