简体   繁体   English

即使在关闭应用程序后,插座仍可以保持活动状态吗?

[英]Is it possible to keep a socket alive even after closing the app?

I have a voip app, and a customer would like to still be available after closing the app. 我有一个voip应用程序,客户希望在关闭该应用程序后仍然可以使用它。 Can I do something to make my app work like facetime? 我可以做一些事情来使我的应用像FaceTime一样工作吗?

The app has to login on our signaling server. 该应用必须登录我们的信令服务器。 The server relays messages like "start a call" to the clients. 服务器将诸如“开始通话”之类的消息中继给客户端。
So if A wants to call B, A has to open a socket and send the login signal (same for B) and then send a "call_create" signal to the server with a parameter "user" set to "B". 因此,如果A想要调用B,则A必须打开套接字并发送登录信号(与B相同),然后将参数“ user”设置为“ B”的“ call_create”信号发送到服务器。 The server then looks at the message, sees that it is meant for B and sends it to B (if B is logged in as well). 然后,服务器查看该消息,发现该消息是针对B的,并将其发送给B(如果B也已登录)。 B now receives the message that A wants to start a call and can send an "accept" back to the server. B现在接收到消息A希望开始呼叫,并且可以将“接受”发送回服务器。 The server sends this message back to A and the call gets started. 服务器将此消息发送回A,呼叫开始。

Now, when the app is closed (double tap home button, swipe up), obviously the socket is killed as well. 现在,当应用程序关闭时(双击主页按钮,向上滑动),显然套接字也被杀死了。 But one of our customers wants to still receive calls after killing the app (long story, but there is no other way). 但是,我们的一位客户希望在终止该应用程序后仍能接听电话(长话短说,但是没有其他方法)。
I know facetime does not have to run to be able to receive calls, but I'm not sure if this is possible with a regular app (facetime is part of the OS). 我知道facetime不必运行就可以接听电话,但是我不确定使用常规应用程序是否可以实现(facetime是操作系统的一部分)。 Ideally I would move the logging in part to the settings menu, just like facetime, and then have a connection with the signaling server all the time, regardless of the app running or not. 理想情况下,我会将日志记录部分地移到“设置”菜单中,就像Facetime一样,然后无论何时运行应用程序都始终与信令服务器保持连接。

looks like you need utilize push notification feature . 看来您需要利用推送通知功能 In case your product supports also android see Google Cloud Messages. 如果您的产品也支持android,请参阅Google Cloud Messages。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM