简体   繁体   English

来自后台服务的 Flutter SIP 呼叫

[英]Flutter SIP call from background service

I'm making a Flutter SIP call application using dart-sip-ua https://github.com/flutter-webrtc/dart-sip-ua .我正在使用 dart-sip-ua https://github.com/flutter-webrtc/dart-sip-ua制作一个 Flutter SIP 呼叫应用程序。 I need to use PUSH messages to wake up the application and set the call.我需要使用 PUSH 消息来唤醒应用程序并设置呼叫。 I was able to wake up the application, but how to connect with the current call?我能够唤醒应用程序,但如何连接当前呼叫?

According to the documentation, when making a call, a Call object is created and it has an answer() method.根据文档,在进行调用时,会创建一个 Call 对象,它有一个answer()方法。 But when the Call object wakes up, we do not have, respectively, the answer() method either.但是当 Call 对象醒来时,我们也相应地没有answer()方法。

I tried to find a solution using SIPUAHelper.findCall(callUUID) , but without success: callUUID is generated when the call is initialized, and we do not know it in advance to pass it via PUSH.我尝试使用SIPUAHelper.findCall(callUUID)找到解决方案,但没有成功:callUUID 是在调用初始化时生成的,我们事先不知道它是通过 PUSH 传递的。

That is, I show my CallScreen, but I don't have a Call object... Is there really only one option?也就是说,我显示了我的 CallScreen,但我没有Call对象......真的只有一个选项吗? Wait until the SIP connects itself?等到 SIP 自己连接? It could be 5, 10, 30 seconds...可能是 5 秒、10 秒、30 秒……

Help me please.请帮帮我。 What is the approach to accomplish this task?完成这项任务的方法是什么? I feel that my approach is not correct.我觉得我的做法不对。

Thank you!谢谢!

One possible solution to your problem could be to store the Call object in a persistent storage, such as a database or a file, whenever it is created.您的问题的一种可能解决方案是在创建 Call 对象时将其存储在持久性存储中,例如数据库或文件。 Then, when the application wakes up and receives the PUSH message, you can retrieve the Call object from the storage and pass it to the CallScreen.然后,当应用程序唤醒并收到 PUSH 消息时,您可以从存储中检索 Call 对象并将其传递给 CallScreen。 To do this, you can use a database library like "sqflite" or a file library like "path_provider" to store and retrieve the Call object as a serialized object.为此,您可以使用像“sqflite”这样的数据库库或像“path_provider”这样的文件库来存储和检索 Call 对象作为序列化对象。

Another option could be to use the "callUUID" of the Call object as a key to store and retrieve it from the storage.另一种选择是使用 Call 对象的“callUUID”作为键来存储它并从存储器中检索它。 You can pass the "callUUID" via PUSH message, and use it to retrieve the Call object from the storage.您可以通过 PUSH 消息传递“callUUID”,并使用它从存储中检索 Call 对象。 However, you need to make sure that the "callUUID" is unique and persistent across sessions, so you may need to use a combination of the SIP call ID and the local session ID.但是,您需要确保“callUUID”在会话中是唯一且持久的,因此您可能需要使用 SIP 呼叫 ID 和本地会话 ID 的组合。

A third option could be to use a global state manager like "Provider" or "Redux" to store the Call object and share it across the application.第三种选择是使用全局状态管理器(如“Provider”或“Redux”)来存储 Call 对象并在应用程序中共享它。 This way, you can access the Call object from any widget, even if it is not passed directly as an argument.这样,您可以从任何小部件访问 Call 对象,即使它没有直接作为参数传递。 However, you need to be careful with the performance and complexity of using a global state manager, especially if you have a large and complex application.但是,您需要注意使用全局状态管理器的性能和复杂性,尤其是当您有一个大型复杂的应用程序时。

I hope these suggestions can help you solve your problem我希望这些建议可以帮助您解决问题

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

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