Closed Del-S closed 9 months ago
@Del-S the TelnyxClient
accepts Context
as a param. Making this a Singleton will dramatically change library implementation. An alternative will be to create a Singleton instance of the TelnyxClient
class. Using DI libraries like Koin or Hilt.
An alternative will be to create a Singleton instance of the TelnyxClient class. Using DI libraries like Koin or Hilt.
It would be if socket could be disconnected and connected again. It would not work properly with Foreground service otherwise.
But I understand why it cannot be singleton so thanks anyway. :)
So imagine havng an app and a Foreground service for calling. If you have just app the socket works fine since the process finishes when the app finishes right? But when using a foreground service the process actually does not finish when the service is stopped. So there is a time when app is not active but the socket connection exists.
Thus a solution is to disconnect the socket when all observers disconnect (app and service). Well we can do that but then the socket cannot be reconnected anymore. So there is only one option. To tear down and recreate the telnyx client.
We have this solution and it seems to work fine but I would prefer to have a Singleton instance of TelnyxClient and just disconnect from the socket and then provide an option to create a new one.