void CChatControl::AddServer(CString Host, UINT Port) { // If server already exists for(int i = 0; i < m_ServerList.size(); i++) { CChatServer* pServer = m_ServerList[i]; if(pServer->m_Host == Host) { if(pServer->m_Status == SOCK_CLOSED) { if(pServer->m_hSocket == INVALID_SOCKET) pServer->Create(); //m_pDoc->LogError("Chat Create Error: " + DWrdtoStr(pServer->GetLastError())); pServer->Connect(Host, Port); } ChatMessage(CHAT_UPDATE, NULL); ChatMessage(CHAT_SELECT, (DWORD) pServer->m_Console); return; } } if(!m_pPrefs->m_DisableIdent) StartIdentd(); CChatServer* Server = new CChatServer(this, Host, Port); //Attempt to connect to node Server->Create(); //m_pDoc->LogError("Chat Create Error: " + DWrdtoStr(Server->GetLastError())); if( !Server->Connect(Host, Port) ) if (Server->GetLastError() != WSAEWOULDBLOCK) { delete Server; return; } // Add node to list m_ServerList.push_back(Server); ChatMessage(CHAT_UPDATE, NULL); }
//----------------------------------------------------------------------------------- // ChatServerMain //----------------------------------------------------------------------------------- int ChatServerMain(int argc, _TCHAR* argv[]) { CChatServer app; CNtlFileStream traceFileStream; // LOG FILE int rc = traceFileStream.Create( "chatlog" ); if( NTL_SUCCESS != rc ) { printf( "log file CreateFile error %d(%s)", rc, NtlGetErrorMessage( rc ) ); return rc; } // CHECK INI FILE AND START PROGRAM NtlSetPrintStream( traceFileStream.GetFilePtr() ); NtlSetPrintFlag( PRINT_APP | PRINT_SYSTEM ); rc = app.Create(argc, argv, ".\\Server.ini"); if( NTL_SUCCESS != rc ) { NTL_PRINT(PRINT_APP, "Server Application Create Fail %d(%s)", rc, NtlGetErrorMessage(rc) ); return rc; } // CONNECT TO MYSQL app.db = new MySQLConnWrapper; app.db->setConfig(app.GetConfigFileHost(), app.GetConfigFileUser(), app.GetConfigFilePassword(), app.GetConfigFileDatabase()); app.db->connect(); app.db->switchDb(app.GetConfigFileDatabase()); app.Start(); Sleep(500); std::cout << "\n\n" << std::endl; std::cout << "\t ____ ____ _ _ " << std::endl; std::cout << "\t | _ \\ _ __ __ _ __ _ ___ _ __ | __ ) __ _| | |" << std::endl; std::cout << "\t | | | | '__/ _` |/ _` |/ _ \\| '_ \\| _ \\ / _` | | |" << std::endl; std::cout << "\t | |_| | | | (_| | (_| | (_) | | | | |_) | (_| | | |" << std::endl; std::cout << "\t |____/|_| \\__,_|\\__, |\\___/|_| |_|____/ \\__,_|_|_|" << std::endl; std::cout << "\t |___/ " << std::endl; std::cout << "\t______ AKCore :O 2014 ______\n\n" << std::endl; app.WaitForTerminate(); return 0; }