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(),
|
tidal_session->GetSession().c_str(),
|
||||||
track_id.c_str(),
|
track_id.c_str(),
|
||||||
handler);
|
handler);
|
||||||
|
track_request->Start();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Failed(std::current_exception());
|
Failed(std::current_exception());
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,6 @@ TidalLoginRequest::TidalLoginRequest(CurlGlobal &curl,
|
|||||||
request.SetOption(CURLOPT_COPYPOSTFIELDS,
|
request.SetOption(CURLOPT_COPYPOSTFIELDS,
|
||||||
EncodeForm(request.Get(),
|
EncodeForm(request.Get(),
|
||||||
{{"username", username}, {"password", password}}).c_str());
|
{{"username", username}, {"password", password}}).c_str());
|
||||||
|
|
||||||
request.StartIndirect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TidalLoginRequest::~TidalLoginRequest() noexcept
|
TidalLoginRequest::~TidalLoginRequest() noexcept
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An asynchronous Tidal "login/username" request.
|
* An asynchronous Tidal "login/username" request.
|
||||||
|
*
|
||||||
|
* After construction, call Start() to initiate the request.
|
||||||
*/
|
*/
|
||||||
class TidalLoginRequest final : CurlResponseHandler {
|
class TidalLoginRequest final : CurlResponseHandler {
|
||||||
CurlSlist request_headers;
|
CurlSlist request_headers;
|
||||||
@ -71,6 +73,10 @@ public:
|
|||||||
|
|
||||||
~TidalLoginRequest() noexcept;
|
~TidalLoginRequest() noexcept;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
request.StartIndirect();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* virtual methods from CurlResponseHandler */
|
/* virtual methods from CurlResponseHandler */
|
||||||
void OnHeaders(unsigned status,
|
void OnHeaders(unsigned status,
|
||||||
|
@ -60,6 +60,7 @@ TidalSessionManager::AddLoginHandler(TidalSessionHandler &h) noexcept
|
|||||||
token,
|
token,
|
||||||
username, password,
|
username, password,
|
||||||
handler);
|
handler);
|
||||||
|
login_request->Start();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
error = std::current_exception();
|
error = std::current_exception();
|
||||||
ScheduleInvokeHandlers();
|
ScheduleInvokeHandlers();
|
||||||
|
@ -61,8 +61,6 @@ TidalTrackRequest::TidalTrackRequest(CurlGlobal &curl,
|
|||||||
request_headers.Append((std::string("X-Tidal-SessionId:")
|
request_headers.Append((std::string("X-Tidal-SessionId:")
|
||||||
+ session).c_str());
|
+ session).c_str());
|
||||||
request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||||
|
|
||||||
request.StartIndirect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TidalTrackRequest::~TidalTrackRequest() noexcept
|
TidalTrackRequest::~TidalTrackRequest() noexcept
|
||||||
|
@ -46,6 +46,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An asynchronous request for the streaming URL of a Tidal track.
|
* An asynchronous request for the streaming URL of a Tidal track.
|
||||||
|
*
|
||||||
|
* After construction, call Start() to initiate the request.
|
||||||
*/
|
*/
|
||||||
class TidalTrackRequest final : CurlResponseHandler {
|
class TidalTrackRequest final : CurlResponseHandler {
|
||||||
CurlSlist request_headers;
|
CurlSlist request_headers;
|
||||||
@ -74,6 +76,10 @@ public:
|
|||||||
|
|
||||||
~TidalTrackRequest() noexcept;
|
~TidalTrackRequest() noexcept;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
request.StartIndirect();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* virtual methods from CurlResponseHandler */
|
/* virtual methods from CurlResponseHandler */
|
||||||
void OnHeaders(unsigned status,
|
void OnHeaders(unsigned status,
|
||||||
|
Loading…
Reference in New Issue
Block a user