Zigonnage dans le srv.

This commit is contained in:
MarcEricMartel
2023-09-24 11:07:03 -04:00
parent 51b0795c62
commit 2bb55e5bf6
5 changed files with 101 additions and 34 deletions

View File

@@ -2,13 +2,13 @@
Connection::Connection(in_addr addr,
std::string name,
UINT64 hash,
UINT64 self_hash,
UINT64 team_hash):
UINT64 id,
UINT64 self_id,
UINT64 team_id):
m_addr(addr),
m_hash(hash),
m_shash(self_hash),
m_thash(team_hash),
m_id(id),
m_sid(self_id),
m_tid(team_id),
m_name(name) {
}
@@ -19,13 +19,38 @@ Connection::~Connection() {
in_addr Connection::GetAddr() const { return m_addr; }
UINT64 Connection::GetHash(bool self) const { return self? m_shash: m_hash; }
UINT64 Connection::GetHash(bool self) const { return self? m_sid: m_id; }
UINT64 Connection::GetTeamHash() const { return m_thash; }
UINT64 Connection::GetTeamHash() const { return m_tid; }
std::string Connection::GetName() const { return m_name; }
void Connection::Clean(std::chrono::system_clock::time_point time) {
while (m_input_manifest.front().timestamp < time || !m_input_manifest.empty())
m_input_manifest.pop_front();
void Connection::AddInput(Input in) {
m_input_manifest.insert({in.timestamp, in});
}
Output* Connection::getOutput(Timestamp time) {
auto out = m_output_manifest.find(time);
if (out != m_output_manifest.end())
return &out->second;
return nullptr;
}
Sync Connection::getSync(Timestamp time) {
Sync sync;
auto out = m_output_manifest.find(time);
if (out != m_output_manifest.end()) {
sync.timestamp = out->second.timestamp;
sync.position = out->second.position;
sync.sid = m_sid;
}
return sync;
}
void Connection::CleanInputManifest(Timestamp time) {
auto wat = m_input_manifest.find(time);
while (wat != m_input_manifest.begin())
m_input_manifest.erase(wat--);
}