2019-03-21 02:34:24 +01:00
|
|
|
/*
|
|
|
|
* IXConnectionState.cpp
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "IXConnectionState.h"
|
|
|
|
|
|
|
|
namespace ix
|
|
|
|
{
|
|
|
|
std::atomic<uint64_t> ConnectionState::_globalId(0);
|
|
|
|
|
2019-09-23 19:25:23 +02:00
|
|
|
ConnectionState::ConnectionState()
|
|
|
|
: _terminated(false)
|
2019-03-21 02:34:24 +01:00
|
|
|
{
|
|
|
|
computeId();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionState::computeId()
|
|
|
|
{
|
2019-03-21 21:50:59 +01:00
|
|
|
_id = std::to_string(_globalId++);
|
2019-03-21 02:34:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& ConnectionState::getId() const
|
|
|
|
{
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<ConnectionState> ConnectionState::createConnectionState()
|
|
|
|
{
|
|
|
|
return std::make_shared<ConnectionState>();
|
|
|
|
}
|
2019-04-18 01:23:24 +02:00
|
|
|
|
2020-08-16 01:03:40 +02:00
|
|
|
void ConnectionState::setOnSetTerminatedCallback(const OnSetTerminatedCallback& callback)
|
|
|
|
{
|
|
|
|
_onSetTerminatedCallback = callback;
|
|
|
|
}
|
|
|
|
|
2019-04-18 01:23:24 +02:00
|
|
|
bool ConnectionState::isTerminated() const
|
|
|
|
{
|
|
|
|
return _terminated;
|
|
|
|
}
|
|
|
|
|
2019-04-18 05:35:00 +02:00
|
|
|
void ConnectionState::setTerminated()
|
2019-04-18 01:23:24 +02:00
|
|
|
{
|
|
|
|
_terminated = true;
|
2020-08-16 01:03:40 +02:00
|
|
|
|
|
|
|
if (_onSetTerminatedCallback)
|
|
|
|
{
|
|
|
|
_onSetTerminatedCallback();
|
|
|
|
}
|
2019-04-18 01:23:24 +02:00
|
|
|
}
|
2020-08-28 23:55:40 +02:00
|
|
|
|
|
|
|
const std::string& ConnectionState::getRemoteIp()
|
|
|
|
{
|
|
|
|
return _remoteIp;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ConnectionState::getRemotePort()
|
|
|
|
{
|
|
|
|
return _remotePort;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionState::setRemoteIp(const std::string& remoteIp)
|
|
|
|
{
|
|
|
|
_remoteIp = remoteIp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectionState::setRemotePort(int remotePort)
|
|
|
|
{
|
|
|
|
_remotePort = remotePort;
|
|
|
|
}
|
2019-09-23 19:25:23 +02:00
|
|
|
} // namespace ix
|