dsbiw2911188 2017-08-17 16:24
浏览 54
已采纳

在Swift中保持套接字打开以进行聊天应用

I have a working chat server in Php/Ratchet. I am using Starscream as my client in Swift. I successfully created a chat between users however this only works when my application is open because this is when the socket is open. How do I make my app receive messages even if my app isn't on. So basically is there a way to keep sockets open. I read somewhere that it is forbidden by Apple.

  • 写回答

2条回答 默认 最新

  • douduan6731 2017-08-17 22:46
    关注

    Sounds like you are sending messages from your client to your phone. You need to send messages to a server and the server sends them to your phone.

    The server, if unable to successfully send a message to your phone, should store the message and should send the stored messages to the phone when the phone is available.

    There are message queuing systems for things like this. See, for example, RabbitMQ. There are loads of others too that may work better with your tech stack. Do some research.

    Here the client talks to the server, the server hooks up with RabbitMQ or whatever you choose to use, RabbitMQ keeps a track of queued messages and when the phone comes online, RabbitMQ sends the queued messages to the server and the server sends them to the phone.

    PS Google "message queue PHP".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败