dongxiongshi9952 2012-03-23 11:16
浏览 72

在iOS客户端实现实时队列

I need to implement a real time queue of items in my iOS App. (later Android too).

The main use case is for a user to see a real time shared queue by all users. there can be many queues, but currently user can only see one queue at a time. If one user deletes item from a queue, all other user of the iOS app viewing the same queue should see the queue updates in real-time. if my server detect that a new item was added to a certain queue, it should be pushed to all other clients viewing that queue in real-time.

What would be the best way to implement such mechanism ? currently supporting only iOS, but it should be an easy solution such that adding other mobile platform later wouldn't be an hassle.

I guess there are 2 main options:

  1. Doing it using web technologies (JS & Html5) (basically presenting a UIWebView)
  2. native way - using apple's push notification or other persistent connection options. (push notification is better if I want to be able to alert user of queue changes even if the app is in the background or god forbidden closed)

Obviously I can choose a hybrid solution as well.

I'm familiar with the following PUB-SUB solution:

1.Xmpp (extension to Xmpp would be more accurate)
2.MQTT
3.Pubnub - http://www.pubnub.com/ (pretty new out there)
4. I read about Linked-in Kafka, but that seems way more advance and complicated to ny current needs.

I'm curious to hear if anyone experimented with any of theses or others, can recommend one, and say if the native or web is the preferred path. The chosen solution have to be something that's easy to use, and fast to implement, even at a cost of a little scale. (the server side is written mostly in php, but node.js is an option as well)

Thanks

  • 写回答

1条回答 默认 最新

  • douxiawei9318 2015-12-17 18:53
    关注

    To update mobile clients (or clients of any type) about the status of your server side queue (or any data system/structure of any type, RDBMS, No-SQL, Files, etc), you could use PubNub.

    Your clients will subscribe to a channel called queue-status (name it whatever you like). Whenever the queue gets update by any client or the server side process, on the successful commit of the change you would publish the change/status to the queue-status channel and all of your actively subscribe clients will get the updates in < 1/4 no matter how many clients there are or where in the world they are located.

    If the client app is registered for APNS (push notifications) on that channel and the app is not running or not in foreground, the client device will receive that push notification.

    Use the PubNub PHP SDK for your server side to publish the messages, and the PubNub iOS SDK to subscribe to receive the messages.

    And don't forget to use PubNub Access Manager to lock down access to your channels.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题