home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / Source Code / Template / netconnect.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  6.4 KB  |  135 lines

  1. //-----------------------------------------------------------------------------
  2. // File: NetConnect.h
  3. //
  4. // Desc:
  5. //-----------------------------------------------------------------------------
  6. #ifndef NETCONNECT_H
  7. #define NETCONNECT_H
  8.  
  9.  
  10. #include <windows.h>
  11. #include <dplay8.h>
  12. #include <dpaddr.h>
  13. #include <tchar.h>
  14.  
  15.  
  16. //-----------------------------------------------------------------------------
  17. // Defines, structures, and error codes
  18. //-----------------------------------------------------------------------------
  19. #define DISPLAY_REFRESH_RATE        250
  20. #define TIMERID_DISPLAY_HOSTS       1
  21. #define TIMERID_CONNECT_COMPLETE    2
  22.  
  23. #define NCW_S_FORWARD      ( (HRESULT) 0x01000001 ) // Dialog success, so go forward
  24. #define NCW_S_BACKUP       ( (HRESULT) 0x01000002 ) // Dialog canceled, show previous dialog
  25. #define NCW_S_QUIT         ( (HRESULT) 0x01000003 ) // Dialog quit, close app
  26. #define NCW_S_LOBBYCONNECT ( (HRESULT) 0x01000004 ) // Dialog connected from lobby, connect success
  27.  
  28. enum SigningType { SIGN_NONE, SIGN_FAST, SIGN_FULL };
  29.  
  30.  
  31. class CNetConnectWizard
  32. {
  33. public:
  34.     CNetConnectWizard( HINSTANCE hInst, HWND hWndParent, TCHAR* strAppName, GUID* pGuidApp );
  35.     virtual ~CNetConnectWizard();
  36.  
  37.     HRESULT WINAPI MessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
  38.     HRESULT WINAPI LobbyMessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
  39.  
  40.     HRESULT Init( IDirectPlay8Peer* pDP, IDirectPlay8LobbiedApplication* pLobbiedApp );
  41.     VOID    Shutdown();
  42.     HRESULT DoConnectWizard( BOOL bBackTrack );
  43.     HRESULT ConnectUsingLobbySettings();
  44.  
  45.     void   SetMaxPlayers( DWORD dwMaxPlayers )                 { m_dwMaxPlayers = dwMaxPlayers; }
  46.     void   SetPlayerName( TCHAR* strPlayerName )               { _tcsncpy( m_strLocalPlayerName, strPlayerName, MAX_PATH-1 ); m_strLocalPlayerName[ MAX_PATH-1 ] = 0; }
  47.     void   SetSessionName( TCHAR* strSessionName )             { _tcsncpy( m_strSessionName, strSessionName, MAX_PATH-1 ); m_strSessionName[ MAX_PATH-1 ] = 0; }
  48.     void   SetPreferredProvider( TCHAR* strPreferredProvider ) { _tcsncpy( m_strPreferredProvider, strPreferredProvider, MAX_PATH-1 ); m_strPreferredProvider[ MAX_PATH-1 ] = 0; }
  49.     void   SetDefaultPort( DWORD dwDefaultPort )               { m_dwPort = dwDefaultPort; }
  50.  
  51.     TCHAR* GetPlayerName()                                     { return m_strLocalPlayerName; }
  52.     TCHAR* GetSessionName()                                    { return m_strSessionName; }
  53.     TCHAR* GetPreferredProvider()                              { return m_strPreferredProvider; }
  54.     BOOL   IsHostPlayer()                                      { return m_bHostPlayer; }
  55.     BOOL   IsMigrateHost()                                     { return m_bMigrateHost; }
  56.     BOOL   HaveConnectionSettingsFromLobby()                   { return m_bHaveConnectionSettingsFromLobby; }
  57.     static BOOL SPRequiresPort( GUID* pSP )                    { return (*pSP != CLSID_DP8SP_MODEM && *pSP != CLSID_DP8SP_SERIAL && *pSP != CLSID_DP8SP_BLUETOOTH); } 
  58.  
  59. protected:
  60.     struct DPHostEnumInfo
  61.     {
  62.         DWORD                 dwRef;
  63.         DPN_APPLICATION_DESC* pAppDesc;
  64.         IDirectPlay8Address* pHostAddr;
  65.         IDirectPlay8Address* pDeviceAddr;
  66.         TCHAR                szSession[MAX_PATH];
  67.         DWORD                dwLastPollTime;
  68.         BOOL                 bValid;
  69.         DPHostEnumInfo*      pNext;
  70.     };
  71.  
  72.     static INT_PTR CALLBACK StaticConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  73.     static INT_PTR CALLBACK StaticSessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  74.     static INT_PTR CALLBACK StaticCreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  75.     static INT_PTR CALLBACK StaticLobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  76.     static INT_PTR CALLBACK StaticAddressDlgProc( HWND, UINT, WPARAM, LPARAM );
  77.     INT_PTR CALLBACK ConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  78.     INT_PTR CALLBACK SessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  79.     INT_PTR CALLBACK CreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  80.     INT_PTR CALLBACK LobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  81.     INT_PTR CALLBACK AddressDlgProc( HWND, UINT, WPARAM, LPARAM );
  82.  
  83.     HRESULT ConnectionsDlgFillListBox( HWND hDlg );
  84.     HRESULT ConnectionsDlgOnOK( HWND hDlg );
  85.     VOID    ConnectionsDlgCleanup( HWND hDlg );
  86.  
  87.     VOID    SessionsDlgInitListbox( HWND hDlg );
  88.     HRESULT SessionsDlgEnumHosts( HWND hDlg );
  89.     VOID    SessionsDlgStopEnumHosts( HWND hDlg );
  90.     VOID    SessionsDlgFinalizeEnumHosts( HWND hDlg );
  91.     HRESULT SessionsDlgNoteEnumResponse( PDPNMSG_ENUM_HOSTS_RESPONSE pEnumHostsResponse );
  92.     VOID    SessionsDlgExpireOldHostEnums();
  93.     HRESULT SessionsDlgDisplayEnumList( HWND hDlg );
  94.     HRESULT SessionsDlgJoinGame( HWND hDlg );
  95.     HRESULT SessionsDlgCreateGame( HWND hDlg );
  96.     VOID    SessionsDlgEnumListCleanup();
  97.  
  98.     IDirectPlay8Peer*       m_pDP;
  99.     IDirectPlay8LobbiedApplication* m_pLobbiedApp;
  100.     CRITICAL_SECTION        m_csHostEnum;
  101.     GUID                    m_guidApp;
  102.     HRESULT                 m_hrDialog;
  103.     HWND                    m_hDlg;
  104.     HINSTANCE               m_hInst;
  105.     HWND                    m_hWndParent;
  106.     DWORD                   m_dwMaxPlayers;
  107.     DWORD                   m_dwPort;
  108.     TCHAR                   m_strAppName[MAX_PATH];
  109.     TCHAR                   m_strPreferredProvider[MAX_PATH];
  110.     TCHAR                   m_strSessionName[MAX_PATH];
  111.     TCHAR                   m_strLocalPlayerName[MAX_PATH];
  112.     TCHAR                   m_strHostname[MAX_PATH];
  113.     BOOL                    m_bSearchingForSessions;
  114.     BOOL                    m_bMigrateHost;
  115.     BOOL                    m_bUseDPNSVR;
  116.     SigningType             m_eSigningType;
  117.     DPHostEnumInfo          m_DPHostEnumHead;
  118.     BOOL                    m_bEnumListChanged;
  119.     DPNHANDLE               m_hEnumAsyncOp;
  120.     BOOL                    m_bHostPlayer;
  121.     DWORD                   m_dwEnumHostExpireInterval;
  122.     BOOL                    m_bConnecting;
  123.     DPNHANDLE               m_hConnectAsyncOp;
  124.     HANDLE                  m_hConnectCompleteEvent;
  125.     HANDLE                  m_hLobbyConnectionEvent;
  126.     HRESULT                 m_hrConnectComplete;
  127.     BOOL                    m_bHaveConnectionSettingsFromLobby;
  128.     DPNHANDLE                m_hLobbyClient;
  129.     GUID                    m_guidSP;
  130. };
  131.  
  132.  
  133. #endif // NETCONNECT_H
  134.  
  135.