0

I want to shut down server on window close (CEFsimple close) by sending http request to localhost:5000/shutdown. I belive this should do the job

 browser->GetMainFrame()->LoadURL("http://127.0.0.1:5000/shutdown/");

So, where is the right place to do that? I have tried with functions like DoClose() and OnBeforeClose()...

grabhints
  • 680
  • 8
  • 23

1 Answers1

1

Making a LoadURL request when the browser is about to close is not guaranteed to succeed, due to the asynchronous nature of Chromium.

I would suggest you to use another library just for that purpose, which can be:

You have to make your HTTP request inside

void OnBeforeClose(CefRefPtr<CefBrowser> browser);

method, which you have to implement after subclassing SimpleHandler from CefLifeSpanHandler and adding also

CefRefPtr<CefLifeSpanHandler> SimpleHandler::GetLifeSpanHandler() { return this; }
Community
  • 1
  • 1
Sga
  • 3,608
  • 2
  • 36
  • 47
  • I am new to CEF and Chromium. It seems like CEF could be run in single thread mode according to [this](https://magpcss.org/ceforum/viewtopic.php?f=6&t=270), no? – HCSF Nov 25 '18 at 15:11
  • Not sure current CEF3 still supports that mode (quite obsolete) – Sga Nov 26 '18 at 16:07