void ClientInterface::DeleteClient(u16 peer_id) { MutexAutoLock conlock(m_clients_mutex); // Error check RemoteClientMap::iterator n = m_clients.find(peer_id); // The client may not exist; clients are immediately removed if their // access is denied, and this event occurs later then. if (n == m_clients.end()) return; /* Mark objects to be not known by the client */ //TODO this should be done by client destructor!!! RemoteClient *client = n->second; // Handle objects for (u16 id : client->m_known_objects) { // Get object ServerActiveObject* obj = m_env->getActiveObject(id); if(obj && obj->m_known_by_count > 0) obj->m_known_by_count--; } // Delete client delete m_clients[peer_id]; m_clients.erase(peer_id); }
void ClientInterface::setClientVersion(u16 peer_id, u8 major, u8 minor, u8 patch, std::string full) { MutexAutoLock conlock(m_clients_mutex); // Error check RemoteClientMap::iterator n = m_clients.find(peer_id); // No client to set versions if (n == m_clients.end()) return; n->second->setVersionInfo(major,minor,patch,full); }
u16 ClientInterface::getProtocolVersion(u16 peer_id) { MutexAutoLock conlock(m_clients_mutex); // Error check RemoteClientMap::iterator n = m_clients.find(peer_id); // No client to get version if (n == m_clients.end()) return 0; return n->second->net_proto_version; }
void ClientInterface::CreateClient(u16 peer_id) { MutexAutoLock conlock(m_clients_mutex); // Error check RemoteClientMap::iterator n = m_clients.find(peer_id); // The client shouldn't already exist if (n != m_clients.end()) return; // Create client RemoteClient *client = new RemoteClient(); client->peer_id = peer_id; m_clients[client->peer_id] = client; }
u16 ClientInterface::getProtocolVersion(u16 peer_id) { JMutexAutoLock conlock(m_clients_mutex); // Error check std::map<u16, RemoteClient*>::iterator n; n = m_clients.find(peer_id); // No client to deliver event if (n == m_clients.end()) return 0; return n->second->net_proto_version; }
void SyncSourceFeedback::run() { Client::initThread("SyncSourceFeedbackThread"); while (true) { { boost::unique_lock<boost::mutex> lock(_mtx); while (!_positionChanged && !_handshakeNeeded) { _cond.wait(lock); } boost::unique_lock<boost::mutex> conlock(_connmtx); const Member* target = replset::BackgroundSync::get()->getSyncTarget(); if (_syncTarget != target) { resetConnection(); _syncTarget = target; } if (!hasConnection()) { // fix connection if need be if (!target) { continue; } if (!_connect(target->fullName())) { continue; } else if (!supportsUpdater()) { _handshakeNeeded = false; _positionChanged = false; continue; } } if (_handshakeNeeded) { if (!replHandshake()) { _handshakeNeeded = true; continue; } else { _handshakeNeeded = false; } } if (_positionChanged) { if (!updateUpstream()) { _positionChanged = true; continue; } else { _positionChanged = false; } } } } }
void ClientInterface::CreateClient(u16 peer_id) { JMutexAutoLock conlock(m_clients_mutex); // Error check std::map<u16, RemoteClient*>::iterator n; n = m_clients.find(peer_id); // The client shouldn't already exist if(n != m_clients.end()) return; // Create client RemoteClient *client = new RemoteClient(m_env); client->peer_id = peer_id; m_clients.set(client->peer_id, client); }