add option to prevent concurrent logins; closes #511

This commit is contained in:
Martin Michelsen
2026-05-17 15:00:32 -07:00
parent cb69dc9c14
commit 7b9b44c191
7 changed files with 32 additions and 5 deletions
+14 -2
View File
@@ -438,9 +438,21 @@ bool Client::can_use_chat_commands() const {
void Client::set_login(shared_ptr<Login> login) {
this->login = login;
auto s = this->require_server_state();
if (!s->allow_same_account_concurrent_logins) {
auto it = s->client_for_account.find(login->account->account_id);
if ((it != s->client_for_account.end()) && (it->second.get() != this)) {
if (it->second->channel) {
it->second->channel->disconnect();
}
s->client_for_account.erase(it);
}
s->client_for_account.emplace(this->login->account->account_id, this->shared_from_this());
}
if (this->log.should_log(phosg::LogLevel::L_INFO)) {
string login_str = this->login->str();
this->log.info_f("Login: {}", login_str);
this->log.info_f("Login: {}", this->login->str());
}
}