Telegraph icon indicating copy to clipboard operation
Telegraph copied to clipboard

Background

Open fluidadsjtr opened this issue 4 years ago • 4 comments

When the app goes it background I understand the server will shutdown, that is fine. But when the app is brought back to foreground it's not restarting. I have tried webserver start but that does not restart it. Can you tell me how to restart?

fluidadsjtr avatar Aug 27 '21 16:08 fluidadsjtr

Hi! I recommend to stop the server when it goes to the background and then to (re)start the server when it comes out of the background. You can use the delegate methods of the AppDelegate for this.

yvbeek avatar Aug 28 '21 20:08 yvbeek

Hi,

How do I stop the server?

Thanks

John

Sent from my iPhone

On 28 Aug 2021, at 22:50, Yvo van Beek @.***> wrote:

 Hi! I recommend to stop the server when it goes to the background and then to (re)start the server when it comes out of the background. You can use the delegate methods of the AppDelegate for this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

fluidadsjtr avatar Aug 29 '21 06:08 fluidadsjtr

The Server object has both a start and a stop function: https://github.com/Building42/Telegraph/blob/main/Sources/Server/Server.swift#L45

You could then for example stop the server in applicationWillResignActive and start it again in applicationWillEnterForeground. You might have to experiment a bit to find out which of the delegate calls works best.

yvbeek avatar Aug 29 '21 18:08 yvbeek

Hey, is there a way to keep the connection open? Need this for authentication with another service... Thanks

mwilzin avatar Jan 14 '22 18:01 mwilzin

Unfortunately on iOS devices, when the app is in the background the operating system will start closing connections for the app to save resources. For more info see https://github.com/Building42/Telegraph#what-if-the-device-goes-on-standby

yvbeek avatar Aug 12 '22 21:08 yvbeek