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()...

4

1 回答 1

1

LoadURL由于 Chromium 的异步特性,无法保证在浏览器即将关闭时发出请求会成功。

我建议您为此目的使用另一个库,它可以是:

你必须在里面发出你的 HTTP 请求

void OnBeforeClose(CefRefPtr<CefBrowser> browser);

方法,您必须在子类化SimpleHandlerCefLifeSpanHandler添加后实现

CefRefPtr<CefLifeSpanHandler> SimpleHandler::GetLifeSpanHandler() { return this; }
于 2015-10-14T13:55:24.570 回答