PopBusDispatcher::ClientPtr PopBusDispatcher::GetOrCreateClient(MojObject& accountId, bool sync) { MojLogTrace(s_log); ClientPtr client; ClientMap::iterator it; it = m_clients.find(accountId); if (it == m_clients.end()) { MojLogInfo(s_log, "Creating PopClient"); shared_ptr<DatabaseInterface> databaseInterface(new MojoDatabase(m_dbClient)); client.reset(new PopClient(databaseInterface, this, accountId, &m_service)); m_clients[accountId] = client; client->CreateSession(); MojLogInfo(s_log, "Setting pop client with account id %s", AsJsonString(accountId).c_str()); } else { client = it->second; } assert(client.get()); MojObject payload; if (sync) { client->SyncAccount(payload); } return client; }
ClientPtr NetServer::getClientFromSerial( ObjSerial serial ) { ClientPtr clt; bool found = false; for (LI li = allClients.begin(); li != allClients.end(); li++) { clt = (*li); Unit *un = clt->game_unit.GetUnit(); if ( un && serial == un->GetSerial() ) { found = true; break; } } if (!found) //cerr<<" WARNING client not found in getClientFromSerial !!!!"<<endl; clt.reset(); return clt; }