#include "StdAfx.h" /* CSSGateManager::CSSGateManager(CSSManager *lpSSManager) :Inherited() { m_dwReconnectSQLTick = 0; m_pSSManager = lpSSManager; m_SQLConnection.SetMultiThread(TRUE); } CSSGateManager::~CSSGateManager() { } BOOL CSSGateManager::ConnectSQL() { TICKCOUNT nCurrentTick = _getTickCount(); if ( !m_SQLConnection.Connected() ) { if ( nCurrentTick >= m_dwReconnectSQLTick ) { if (NULL ==m_pSSManager) return FALSE; m_pSSManager->SetupSQLConnection(&m_SQLConnection); if ( m_SQLConnection.Connect() ) { mysql_options(m_SQLConnection.GetMySql(), MYSQL_SET_CHARSET_NAME, "utf8"); //if (m_SQLConnection.Exec("charset utf8")) //{ // OutputMsg( rmError, _T("设置utf8字符编码出错!!!")); //} //else //{ // m_SQLConnection.ResetQuery(); //} return TRUE; } OutputMsg( rmError, "连接数据库ip=%s,port=%d失败", m_SQLConnection.GetServerHost(),m_SQLConnection.GetServerPort()); //如果连接SQL失败则将在5秒后重试 m_dwReconnectSQLTick = _getTickCount() + 5 * 1000; return FALSE; } } else { if( nCurrentTick> m_dwDumpTime) { if(m_dwDumpTime ) { if(m_dwDumpTime) { CTimeProfMgr::getSingleton().dump(); } } m_dwDumpTime = nCurrentTick + 300000; //5分钟打印一次 } } return TRUE; } VOID CSSGateManager::ResultUserSessionConfim(const int nSessionId, const BOOL boOnline) { CSSGate *pGate; for ( int i=0; im_UserList.count() > 0) { if ( pGate->ResultGateUserSessionConfim(nSessionId, boOnline) ) { break; } } } } //打开一个session VOID CSSGateManager::OnResultConformOpenSession(int nSessionId, int nServerIndex) { CSSGate *pGate; for ( int i=0; im_UserList.count() > 0) { if ( pGate->ResultOpenSession(nSessionId,nServerIndex) ) { break; } } } } VOID CSSGateManager::Initialize() { int i; for ( i=0; i