Exemple #1
0
void CClientDlg::OnBnClickedGSUpdateList()
{
	UpdateData();
	
	// if we're doing an update, cancel it
	SBState state = ServerBrowserState(m_serverBrowser);
	if((state != sb_connected) && (state != sb_disconnected))
	{
		ServerBrowserHalt(m_serverBrowser);
//		m_pGameSpyUpdateList.EnableWindow(TRUE);
//		m_pGameSpyRefreshList.EnableWindow(TRUE);
//		MessageBox("GameSpy Refresh Stopped\n");

//		m_pGameSpyUpdateList.EnableWindow(TRUE);
//		m_pGameSpyRefreshList.EnableWindow(TRUE);
		if (m_timerID)
			KillTimer(m_timerID);
		m_timerID = 0;

//		return;
	};

//	m_pGameSpyUpdateList.EnableWindow(FALSE);
//	m_pGameSpyRefreshList.EnableWindow(FALSE);

	// clear the server browser and list
	ServerBrowserClear(m_serverBrowser);
	ClearHostList();
	m_pBtnJoin.EnableWindow(FALSE);

	// set a timer
	if(!m_timerID)
		m_timerID = SetTimer(TIMER_ID, TIMER_FREQUENCY, NULL);

	// fields we're interested in
	unsigned char fields[] = { HOSTNAME_KEY, NUMPLAYERS_KEY, MAXPLAYERS_KEY, MAPNAME_KEY, GAMETYPE_KEY, PASSWORD_KEY, HOSTPORT_KEY };
	int numFields = sizeof(fields) / sizeof(fields[0]);

	// check for internet/lan
	bool internet = (IsDlgButtonChecked(IDC_INTERNET) == BST_CHECKED);

	// do an update
	SBError error;
	if(internet)
		error = ServerBrowserUpdate(m_serverBrowser, SBTrue, SBFalse, fields, numFields, (char *)(const char *)"");
	else
		error = ServerBrowserLANUpdate(m_serverBrowser, SBTrue, START_PORT_LAN, END_PORT_LAN);

	if (error != sbe_noerror)
	{
		MessageBox("GameSpy Error!", "Error", MB_OK);
		m_pGameSpyUpdateList.EnableWindow(TRUE);
		m_pGameSpyRefreshList.EnableWindow(TRUE);
		if (m_timerID)
			KillTimer(m_timerID);
		m_timerID = 0;
	}
}
void CSbmfcsampleDlg::OnRefresh() 
{
	UpdateData();

	// create the server list if we need to
	if(!CreateServerList())
		return;

	// if we're doing an update, cancel it
	SBState state = ServerBrowserState(m_serverBrowser);
	if((state != sb_connected) && (state != sb_disconnected))
	{
		ServerBrowserHalt(m_serverBrowser);
		return;
	}

	// clear the server browser and list
	ServerBrowserClear(m_serverBrowser);
	m_serverList.DeleteAllItems();

	// clear the progress bar
	m_progress.SetPos(0);

	// clear the server count
	m_serverCount = 0;
	m_servers.SetWindowText("0");

	// set a timer
	if(!m_timerID)
		m_timerID = SetTimer(TIMER_ID, TIMER_FREQUENCY, NULL);

	// fields we're interested in
	unsigned char fields[] = { HOSTNAME_KEY, NUMPLAYERS_KEY, MAXPLAYERS_KEY, MAPNAME_KEY, GAMETYPE_KEY };
	int numFields = sizeof(fields) / sizeof(fields[0]);

	// check for internet/lan
	bool internet = (IsDlgButtonChecked(IDC_INTERNET) == BST_CHECKED);

	// do an update
	SBError error;
	if(internet)
		error = ServerBrowserUpdate(m_serverBrowser, SBTrue, SBFalse, fields, numFields, (char *)(const char *)m_filter);
	else
		error = ServerBrowserLANUpdate(m_serverBrowser, SBTrue, (unsigned short)m_startPort, (unsigned short)m_endPort);
}