BOOL CVersionManagerDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_Iocport.Init( MAX_USER, CLIENT_SOCKSIZE, 1 );
	
	for (int i=0; i<MAX_USER; i++)
		m_Iocport.m_SockArrayInActive[i] = new CUser;

	if (!m_Iocport.Listen(_LISTEN_PORT))
	{
		AfxMessageBox("Failed to listen on server port.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	GetInfoFromIni();
	
	char strConnection[256];
	sprintf_s(strConnection, sizeof(strConnection), "ODBC;DSN=%s;UID=%s;PWD=%s", m_ODBCName, m_ODBCLogin, m_ODBCPwd);

	if (!m_DBProcess.InitDatabase(strConnection)) 
	{
		AfxMessageBox("Unable to connect to the database using the details configured.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	if (!m_DBProcess.LoadVersionList())
	{
		AfxMessageBox("Unable to load the version list.");
		AfxPostQuitMessage(0);
		return FALSE;
	}

	m_OutputList.AddString(strConnection);
	CString version;
	version.Format("Latest Version : %d", m_nLastVersion);
	m_OutputList.AddString( version );

	::ResumeThread(m_Iocport.m_hAcceptThread);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
示例#2
0
bool LoginServer::Startup()
{
	GetInfoFromIni();

	DateTime time;

	CreateDirectory("Logs",NULL);

	m_fpLoginServer = fopen("./Logs/LoginServer.log", "a");
	if (m_fpLoginServer == nullptr)
	{
		printf("ERROR: Unable to open log file.\n");
		return false;
	}

	m_fpUser = fopen(string_format("./Logs/Login_%d_%d_%d.log",time.GetDay(),time.GetMonth(),time.GetYear()).c_str(), "a");
	if (m_fpUser == nullptr)
	{
		printf("ERROR: Unable to open user log file.\n");
		return false;
	}

	if (!m_DBProcess.Connect(m_ODBCName, m_ODBCLogin, m_ODBCPwd)) 
	{
		printf("ERROR: Unable to connect to the database using the details configured.\n");
		return false;
	}

	printf("Connected to database server.\n");
	if (!m_DBProcess.LoadVersionList())
	{
		printf("ERROR: Unable to load the version list.\n");
		return false;
	}

	printf("Latest version in database: %d\n", GetVersion());
	InitPacketHandlers();

	if (!m_socketMgr.Listen(m_LoginServerPort, MAX_USER))
	{
		printf("ERROR: Failed to listen on server port.\n");
		return false;
	}

	m_socketMgr.RunServer();
	g_timerThreads.push_back(new Thread(Timer_UpdateUserCount));
	return true;
}
示例#3
0
bool LoginServer::Startup()
{
	GetInfoFromIni();

	m_fp = fopen("./Login.log", "a");
	if (m_fp == nullptr)
	{
		printf("ERROR: Unable to open log file.\n");
		return false;
	}

	if (!m_DBProcess.Connect(m_ODBCName, m_ODBCLogin, m_ODBCPwd)) 
	{
		printf("ERROR: Unable to connect to the database using the details configured.\n");
		return false;
	}

	printf("Connected to database server.\n");
	if (!m_DBProcess.LoadVersionList())
	{
		printf("ERROR: Unable to load the version list.\n");
		return false;
	}

	printf("Latest version in database: %d\n", GetVersion());
	InitPacketHandlers();

	if (!m_socketMgr.Listen(_LISTEN_PORT, MAX_USER))
	{
		printf("ERROR: Failed to listen on server port.\n");
		return false;
	}

	m_socketMgr.RunServer();
	g_timerThreads.push_back(new Thread(Timer_UpdateUserCount));
	return true;
}