2015-03-31 14:00:40 -04:00
|
|
|
#pragma once
|
|
|
|
#include <api/ApiServer.h>
|
|
|
|
#include <util/rsthreads.h>
|
|
|
|
|
|
|
|
namespace resource_api {
|
|
|
|
|
|
|
|
// allows basic control from stdin/stdout
|
|
|
|
// - account selection
|
|
|
|
// - login
|
|
|
|
// - shutdown
|
2015-06-16 08:35:07 -04:00
|
|
|
class TerminalApiClient: private RsTickingThread{
|
2015-03-31 14:00:40 -04:00
|
|
|
public:
|
|
|
|
// zero setup: create an instance of this class and destroy it when not needed anymore
|
|
|
|
// no need to call start or stop or something
|
|
|
|
// parameter api must not be null
|
|
|
|
TerminalApiClient(ApiServer* api);
|
|
|
|
~TerminalApiClient();
|
|
|
|
protected:
|
|
|
|
// from RsThread
|
2015-06-16 08:35:07 -04:00
|
|
|
virtual void data_tick(); /* called once the thread is started. Should be overloaded by subclasses. */
|
2015-03-31 14:00:40 -04:00
|
|
|
private:
|
|
|
|
void waitForResponse(ApiServer::RequestId id);
|
|
|
|
bool isTokenValid(StateToken st);
|
|
|
|
ApiServer* mApiServer;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace resource_api
|