#define MS_CLASS "mocks::MockShared"
#include "mocks/include/MockShared.hpp"
#include "Logger.hpp"
#include "mocks/include/handles/MockTimerHandle.hpp"
namespace mocks
{
MockShared::MockShared(std::function<uint64_t()> getTimeMs)
: getTimeMs(std::move(getTimeMs)),
channelSocket(new ::Channel::ChannelSocket()),
channelMessageRegistrator(new mocks::Channel::MockChannelMessageRegistrator()),
channelNotifier(new ::Channel::ChannelNotifier(this->channelSocket.get()))
{
MS_TRACE();
}
TimerHandleInterface* MockShared::CreateTimer(TimerHandleInterface::Listener* )
{
MS_TRACE();
return new MockTimerHandle();
}
BackoffTimerHandleInterface* MockShared::CreateBackoffTimer(
const BackoffTimerHandleInterface::BackoffTimerHandleOptions& options)
{
MS_TRACE();
const auto& label = options.label;
auto* backoffTimer = new MockBackoffTimerHandle(
options,
this->getTimeMs,
[this, label]()
{
this->backoffTimers.erase(label);
});
this->backoffTimers[options.label] = backoffTimer;
return backoffTimer;
}
}