bool CDatabase::closeConnection(IConnection *pConnection) { TConnections::iterator it = m_Connections.find(IConnectionPtr(pConnection)); if(it == m_Connections.end()) return false; // TO DO Log m_Connections.erase(it); return true; }
IConnectionPtr CDatabase::connect(const wchar_t* pszUser, const wchar_t* pszPassword) { if(!m_UserCryptoManager.CheckUser(pszUser, pszPassword)) { return IConnectionPtr(); // TO DO Log error } if(!m_bLoad) { if(!load()) return IConnectionPtr(); // TO DO Log error m_bLoad = true; } uint64 nUserID = m_UserCryptoManager.GetUserID(pszUser); eUserGroup userGroup = m_UserCryptoManager.GetUserGroup(pszUser); CConnection *pConnection = new CConnection(this, m_pSchema.get(), pszUser, nUserID, userGroup); m_Connections.insert(IConnectionPtr(pConnection)); return IConnectionPtr(pConnection); }
// Let your server know about your connection. IConnectionPtr createConnection() override { return IConnectionPtr( new MyConnection( m_ioService, this, createTask() ) ); }