通过本地网络从设备到设备推送通知,无需 C2DM
我将有两台在同一零售地点工作的 Android 平板电脑,它们都连接到本地网络。
客户将使用一台平板电脑下订单。下订单时,该平板电脑需要向另一台平板电脑发送通知。
我正在使用 MySql 数据库,我可以从需要接收信息的平板电脑上不断轮询,但这会耗尽电池。
我可以使用 C2DM,但即使互联网速度变慢/连接丢失,系统也绝对有必要正常工作。
我怎样才能通过本地网络实现从 Android 设备到 Android 设备的基本上 C2DM 的操作?任何 Android 设备都不会提供手机服务。
I will have two android tablets working in the same retail location, both connected to a local network.
A customer will use one tablet to place an order. That tablet needs to send a notification to another tablet when the order is placed.
I am using a MySql database, and I could poll constantly from the tablet that needs to receive information, but that would drain the battery.
I could use C2DM, but it is absolutely necessary that the system works even if there is an internet slowdown/loss of connectivity.
How can I do what is basically C2DM over a local network from android device to android device? No android device will have cell phone service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在引入 C2DM 之前,我们使用 XMPP 协议来提供推送通知。完成该功能的最佳库是 阿斯马克。
尽管如此,C2DM 在连接丢失的情况下也能完美工作(当您重新连接时,您会收到丢失的消息)
Before the introduction of C2DM we used the XMPP protocol to provide Push Notification.. the best library to acomplish that function was asmack.
Althought, C2DM works perfectly with loss of connectivity (when you reconnect you receive the missed messages)
您问了一个一般性问题,所以我所能做的就是给您一个一般性答案。传统上,在这种情况下使用长轮询。本质上,第一个平板电脑轮询第二个平板电脑。当第二个平板电脑收到轮询请求时,它只是停留在上面,直到它实际上有东西要告诉另一个设备。一旦有消息要发送到其他设备,它就会响应初始轮询请求。
You've asked a general question so the best I can do is give you a general answer. Traditionally, Long Polling has been used in this situation. Essentially, the first tablet polls the second tablet. When the second tablet gets the poll request it just sits on it until it actually has something to tell the other device. Once it has a message to send to the other device, it responds to that initial poll request.