Implemented SinglePoolStrategy.
This commit is contained in:
parent
bd8776b7ee
commit
25faeabd61
10 changed files with 98 additions and 22 deletions
|
@ -22,12 +22,14 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "interfaces/IStrategyListener.h"
|
||||
#include "net/Client.h"
|
||||
#include "net/strategies/SinglePoolStrategy.h"
|
||||
#include "Options.h"
|
||||
|
||||
|
||||
SinglePoolStrategy::SinglePoolStrategy(const Url *url, const char *agent, IStrategyListener *listener) :
|
||||
m_active(false),
|
||||
m_listener(listener)
|
||||
{
|
||||
m_client = new Client(0, agent, this);
|
||||
|
@ -36,24 +38,43 @@ SinglePoolStrategy::SinglePoolStrategy(const Url *url, const char *agent, IStrat
|
|||
}
|
||||
|
||||
|
||||
bool SinglePoolStrategy::isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::connect()
|
||||
{
|
||||
m_client->connect();
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::submit(const JobResult &result)
|
||||
{
|
||||
m_client->submit(result);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onClose(Client *client, int failures)
|
||||
{
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_active = false;
|
||||
m_listener->onPause(this);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onJobReceived(Client *client, const Job &job)
|
||||
{
|
||||
|
||||
m_listener->onJob(client, job);
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::onLoginSuccess(Client *client)
|
||||
{
|
||||
m_active = true;
|
||||
m_listener->onActive(client);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue