home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / Common / include / netconnect.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  5.5 KB  |  126 lines

  1. //-----------------------------------------------------------------------------
  2. // File: NetConnect.h
  3. //
  4. // Desc:
  5. //
  6. // Copyright (C) 2000-2001 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef NETCONNECT_H
  9. #define NETCONNECT_H
  10.  
  11.  
  12. #include <windows.h>
  13. #include <dplay8.h>
  14. #include <dpaddr.h>
  15. #include <tchar.h>
  16.  
  17.  
  18. //-----------------------------------------------------------------------------
  19. // Defines, structures, and error codes
  20. //-----------------------------------------------------------------------------
  21. #define DISPLAY_REFRESH_RATE        250
  22. #define TIMERID_DISPLAY_HOSTS       1
  23. #define TIMERID_CONNECT_COMPLETE    2
  24.  
  25. #define NCW_S_FORWARD      0x01000001  // Dialog success, so go forward
  26. #define NCW_S_BACKUP       0x01000002  // Dialog canceled, show previous dialog
  27. #define NCW_S_QUIT         0x01000003  // Dialog quit, close app
  28. #define NCW_S_LOBBYCONNECT 0x01000004  // Dialog connected from lobby, connect success
  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.     VOID    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 )               { _tcscpy( m_strLocalPlayerName, strPlayerName ); }
  47.     void   SetSessionName( TCHAR* strSessionName )             { _tcscpy( m_strSessionName, strSessionName ); }
  48.     void   SetPreferredProvider( TCHAR* strPreferredProvider ) { _tcscpy( m_strPreferredProvider, strPreferredProvider ); }
  49.  
  50.     TCHAR* GetPlayerName()                                     { return m_strLocalPlayerName; }
  51.     TCHAR* GetSessionName()                                    { return m_strSessionName; }
  52.     TCHAR* GetPreferredProvider()                              { return m_strPreferredProvider; }
  53.     BOOL   IsHostPlayer()                                      { return m_bHostPlayer; }
  54.     BOOL   IsMigrateHost()                                     { return m_bMigrateHost; }
  55.     BOOL   HaveConnectionSettingsFromLobby()                   { return m_bHaveConnectionSettingsFromLobby; }
  56.  
  57. protected:
  58.     struct DPHostEnumInfo
  59.     {
  60.         DWORD                 dwRef;
  61.         DPN_APPLICATION_DESC* pAppDesc;
  62.         IDirectPlay8Address* pHostAddr;
  63.         IDirectPlay8Address* pDeviceAddr;
  64.         TCHAR                szSession[MAX_PATH];
  65.         DWORD                dwLastPollTime;
  66.         BOOL                 bValid;
  67.         DPHostEnumInfo*      pNext;
  68.     };
  69.  
  70.     static INT_PTR CALLBACK StaticConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  71.     static INT_PTR CALLBACK StaticSessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  72.     static INT_PTR CALLBACK StaticCreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  73.     static INT_PTR CALLBACK StaticLobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  74.     INT_PTR CALLBACK ConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  75.     INT_PTR CALLBACK SessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  76.     INT_PTR CALLBACK CreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  77.     INT_PTR CALLBACK LobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  78.  
  79.     HRESULT ConnectionsDlgFillListBox( HWND hDlg );
  80.     HRESULT ConnectionsDlgOnOK( HWND hDlg );
  81.     VOID    ConnectionsDlgCleanup( HWND hDlg );
  82.  
  83.     VOID    SessionsDlgInitListbox( HWND hDlg );
  84.     HRESULT SessionsDlgEnumHosts( HWND hDlg );
  85.     HRESULT SessionsDlgNoteEnumResponse( PDPNMSG_ENUM_HOSTS_RESPONSE pEnumHostsResponse );
  86.     VOID    SessionsDlgExpireOldHostEnums();
  87.     HRESULT SessionsDlgDisplayEnumList( HWND hDlg );
  88.     HRESULT SessionsDlgJoinGame( HWND hDlg );
  89.     HRESULT SessionsDlgCreateGame( HWND hDlg );
  90.     VOID    SessionsDlgEnumListCleanup();
  91.  
  92.     IDirectPlay8Peer*       m_pDP;
  93.     IDirectPlay8LobbiedApplication* m_pLobbiedApp;
  94.     CRITICAL_SECTION        m_csHostEnum;
  95.     GUID                    m_guidApp;
  96.     HRESULT                 m_hrDialog;
  97.     HWND                    m_hDlg;
  98.     HINSTANCE               m_hInst;
  99.     HWND                    m_hWndParent;
  100.     DWORD                   m_dwMaxPlayers;
  101.     TCHAR                   m_strAppName[MAX_PATH];
  102.     TCHAR                   m_strPreferredProvider[MAX_PATH];
  103.     TCHAR                   m_strSessionName[MAX_PATH];
  104.     TCHAR                   m_strLocalPlayerName[MAX_PATH];
  105.     BOOL                    m_bSearchingForSessions;
  106.     BOOL                    m_bMigrateHost;
  107.     IDirectPlay8Address*    m_pDeviceAddress;
  108.     IDirectPlay8Address*    m_pHostAddress;
  109.     DPHostEnumInfo          m_DPHostEnumHead;
  110.     BOOL                    m_bEnumListChanged;
  111.     DPNHANDLE               m_hEnumAsyncOp;
  112.     BOOL                    m_bHostPlayer;
  113.     DWORD                   m_dwEnumHostExpireInterval;
  114.     BOOL                    m_bConnecting;
  115.     DPNHANDLE               m_hConnectAsyncOp;
  116.     HANDLE                  m_hConnectCompleteEvent;
  117.     HANDLE                  m_hLobbyConnectionEvent;
  118.     HRESULT                 m_hrConnectComplete;
  119.     BOOL                    m_bHaveConnectionSettingsFromLobby;
  120.     DPNHANDLE                m_hLobbyClient;
  121. };
  122.  
  123.  
  124. #endif // NETCONNECT_H
  125.  
  126.