//////////////////////////////////////////////////////////////////////////////
//
// Asura_Xbox360_MatchFinder.h
//
// Copyright (c) 2008 Rebellion. All rights reserved.
//
// Description:
//
//     class to manage searching for Xbox Live Sessions. This class is 
//     intended to be completely independent of Asura_Lobby.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ASURA_XBOX360_MATCHFINDER_H___
#define ASURA_XBOX360_MATCHFINDER_H___ 1

// do not include Asura_Lobby.h etc.
#include <Winsockx.h>
#include <xbox.h>

class Asura_Xbox360_MatchFinder
{
public:

	Asura_Xbox360_MatchFinder( u_int uMaxResults, u_int uMaxContexts, bool bRankedGames );
	~Asura_Xbox360_MatchFinder();

	bool BeginSearch();
	bool IsSearchComplete();

	u_int GetNumSearchResults() const;
	const XSESSION_SEARCHRESULT& GetResult( u_int uIndex ) const;

	// functions for setting search criteria
	void ResetPropertiesAndContexts( u_int uGameMode = 0 );
	void AddSearchContext( u_int uContextID, u_int uContextValue );
	void AddSearchProperty( u_int uPropertyID, int iPropertyValue );

private:

	u_int							m_uMaxResults;
	u_int							m_uMaxContexts;
	XUSER_CONTEXT*					m_pxContexts;
	u_int							m_uNumContexts;
	u_int							m_uMaxProperties;
	XUSER_PROPERTY*					m_pxProperties;
	u_int							m_uNumProperties;
	XOVERLAPPED						m_xSearchOverlapped;
	XSESSION_SEARCHRESULT_HEADER*	m_pxSearchResults;
	bool                            m_bRankedGames;
	bool               				m_bQoSTesting;
	XNQOS              				m_xQoSResult;
	XNQOS*             				m_pxQoSResult;
	const XNADDR**     				m_ppxQoSxnaddr;
	const XNKID**      				m_ppxQoSxnkid;
	const XNKEY**      				m_ppxQoSxnkey;
};

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ASURA_XBOX360_MATCHFINDER_H___
