java - 使用 reSTLet 进行异步 Android GAE 通信

标签 java android google-app-engine restlet

我想重复(每秒)从另一个 Android 设备向 GAE 请求消息(对象或值)(如果 Android 客户端没有在那里创建或更改某些内容)。我需要非常快地检查它,但我知道它大约每小时发生一次。

我使用reSTLet,我不想创建新线程并每秒从该线程获取轮询,因为这非常消耗电池。我也不想使用C2DM。

是否有可能做到这一点?我在这里找到了一些关于 NIO 非阻塞 http 连接器的信息: http://restlet-code.1609877.n2.nabble.com/Push-data-from-server-using-a-live-HTTP-connection-td2906563.html

但是这里只描述了客户端,我也不知道这个解决方案是否可以在 GAE 上使用以及如何使用。有谁对这种方法了解更多?

提前非常感谢您。

最佳答案

作为 uniqush 的作者,我在 FAQ 中创建了一个条目针对此问题的页面。

Can I use uniqush on Google App Engine?

Yes and no.

If you just want to use GCM on Google App Engine, then there are some code in uniqush-push which you can directly use.

However, because Google App Engine does not support socket connection, there is no way to use APNS. In another work, if you want to setup a server on Google App Engine, you cannot push any notification to iOS devices no matter what software/library you are using.

I did considered to port uniqush to Google App Engine. But because of this fact, I think it may be better to port it until Google let us use client-side socket connections, or provide some way to connect to APNS server.

Again, if you are considering to use Google App Engine as a server for your App, please be aware that you will not be able to push notification to any iOS device right now. If this fact does not bother you, then do it.

Personally, I recommend you to run a server with full control. It is not expensive nowadays. Amazon EC2 or similar cloud products may be a good choice to run uniqush.

正如我上面建议的,如果您想支持除 Android 之外的更多平台,使用具有完全控制权的(虚拟)服务器将是更好的选择。

如有其他问题,欢迎回复。

关于java - 使用 reSTLet 进行异步 Android GAE 通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11313285/

相关文章:

java - 从属性文件生成代码

android - 需要列约束或逗号,得到文本

java - 加载奖励视频广告时显示进度条

Python:为什么这段代码会永远(无限循环?)

python - pydev 调试器不会在断点处停止

java - 为什么 JSoup 不读取页面的所有元素?

java - 如何解决java中的响应代码406错误?

java - 信号量被多次中断的问题

java - ListView 中的复选框无法正常工作?

java - 获取 java.lang.NoSuchFieldError : usingExperimentalRuntime in GAE MemCache