input/Tidal*Request: add Start() method
The caller should be able to safely store the instance pointer before his callback is invoked.
This commit is contained in:
parent
1ecad094bd
commit
2fed3b5e5b
@ -91,6 +91,7 @@ TidalInputStream::OnTidalSession() noexcept
|
||||
tidal_session->GetSession().c_str(),
|
||||
track_id.c_str(),
|
||||
handler);
|
||||
track_request->Start();
|
||||
} catch (...) {
|
||||
Failed(std::current_exception());
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ TidalLoginRequest::TidalLoginRequest(CurlGlobal &curl,
|
||||
request.SetOption(CURLOPT_COPYPOSTFIELDS,
|
||||
EncodeForm(request.Get(),
|
||||
{{"username", username}, {"password", password}}).c_str());
|
||||
|
||||
request.StartIndirect();
|
||||
}
|
||||
|
||||
TidalLoginRequest::~TidalLoginRequest() noexcept
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
|
||||
/**
|
||||
* An asynchronous Tidal "login/username" request.
|
||||
*
|
||||
* After construction, call Start() to initiate the request.
|
||||
*/
|
||||
class TidalLoginRequest final : CurlResponseHandler {
|
||||
CurlSlist request_headers;
|
||||
@ -71,6 +73,10 @@ public:
|
||||
|
||||
~TidalLoginRequest() noexcept;
|
||||
|
||||
void Start() {
|
||||
request.StartIndirect();
|
||||
}
|
||||
|
||||
private:
|
||||
/* virtual methods from CurlResponseHandler */
|
||||
void OnHeaders(unsigned status,
|
||||
|
@ -60,6 +60,7 @@ TidalSessionManager::AddLoginHandler(TidalSessionHandler &h) noexcept
|
||||
token,
|
||||
username, password,
|
||||
handler);
|
||||
login_request->Start();
|
||||
} catch (...) {
|
||||
error = std::current_exception();
|
||||
ScheduleInvokeHandlers();
|
||||
|
@ -61,8 +61,6 @@ TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl,
|
||||
request_headers.Append((std::string("X-Tidal-SessionId:")
|
||||
+ session).c_str());
|
||||
request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||
|
||||
request.StartIndirect();
|
||||
}
|
||||
|
||||
TidalTrackRequest::~TidalTrackRequest() noexcept
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
|
||||
/**
|
||||
* An asynchronous request for the streaming URL of a Tidal track.
|
||||
*
|
||||
* After construction, call Start() to initiate the request.
|
||||
*/
|
||||
class TidalTrackRequest final : CurlResponseHandler {
|
||||
CurlSlist request_headers;
|
||||
@ -74,6 +76,10 @@ public:
|
||||
|
||||
~TidalTrackRequest() noexcept;
|
||||
|
||||
void Start() {
|
||||
request.StartIndirect();
|
||||
}
|
||||
|
||||
private:
|
||||
/* virtual methods from CurlResponseHandler */
|
||||
void OnHeaders(unsigned status,
|
||||
|
Loading…
Reference in New Issue
Block a user