// AMSClient.h: interface for the CAMSClient class. // ////////////////////////////////////////////////////////////////////// #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define WM_SEARCH_NOTIFY ( WM_USER + 100 ) class CQLConnect; #include "QLClientSocket.h" #include "QLCommander.h" #include "QLResponse.h" #include "QLRequest.h" #include "QLNotify.h" // Socket ÔÚĬÈÏÇé¿öÏÂÊÇ·ñ¿É½øÐмì²â #define SOCKET_CHECK_DEFAULT true typedef CList CConnectionList; typedef struct _VERUPDATE { DWORD dwVersion; CString strModule; CString strDescType; CString strDesc; _VERUPDATE() : dwVersion( 0 ) {}; } VERUPDATE; class CQLClient : public CWnd { public: CQLClient(); virtual ~CQLClient(); public: // Attributers public: CQLClientSocket *m_pNotifySock; // Ö÷ Socket CQLManualResetEvent m_EventFreeSocket; CQLConnect *m_pConnect; // ÔڵǼʱ֪ͨÓà CQLNotify *m_pNotify; // ·þÎñÆ÷֪ͨÓÃÕâ¸ö¶ÔÏóת·¢ DWORD m_dwVersion; // µ±Ç°°æ±¾ºÅ bool m_bConnectMastServer; CString m_strMastServer; int m_nMastServerPort; CString m_strSignServer; int m_nSignServerPort; CString m_strMsgServer; int m_nMsgServerPort; DWORD m_dwUserID; CString m_strLoginName; CString m_strPassword; CString m_strDispName; long m_nUserType; // Óû§ÀàÐÍ 0ÆÕͨÓû§ 1ÄäÃûÓû§ 2ϵͳÓû§ long m_nUserSex; long m_lFlag; // Login Flag CString m_strAppType; // µÇ¼µÄÓ¦ÓÃÀàÐÍ CString m_strSessionID; // µÇ¼ºóµÄSession ID CString m_strServerID; CString m_strVerifyMD5; CString m_strConnectIP; // ³ö¿ÚIP CString m_strLocalIP; // ±¾»úIP static DWORD m_dwTrID; // ´úÀí·þÎñÆ÷ QLPROXYINFO m_infoProxy; // CMapPtrToPtr m_mapBusyConnection; CConnectionList m_listFreeConnection; HANDLE m_hSearchServer; // Òì²½²éÕÒ·þÎñÆ÷µÄHandle CByteArray m_bufSearchServer; // ΪÒì²½²éÕÒ·þÎñÆ÷Ìṩ»º´æ in_addr m_address; // ±£´æÕÒµ½µÄ·þÎñÆ÷µØÖ· CTime m_lastCheckTime; // ×îºó¼ì²âʱ¼ä CTime m_lastChallengesTime; // ×îºóÏìÓ¦·þÎñÆ÷µÄʱ¼ä int m_nLifetime; // ·þÎñÆ÷¹ý¶à³¤Ê±¼ä»á·¢¹ýÀ´"CHL"Ö¸Ãü int m_nFreeConnectCount; // ³£ÓÃÁ¬½ÓµÄ¸öÊý int m_nMaxFreeConnectCount; // ×î¶àµÄ³£ÓÃÁ¬½Ó¸öÊý int m_nLifeSpace; // ·¢¿Õ°ü¼ä¸ôµÄʱ¼ä int m_nTranTimeout; // ´«Ê䳬ʱʱ¼ä£¬Ãë // Operations public: void SetOIConnect( CQLConnect *pConnect ); void SetOINotify( CQLNotify *pNotify ); void SetTimeout( int nSecond = 20 ); void SetVersion( DWORD dwVersion ); void SetSignInNty( HWND hWnd, DWORD dwMsg ); void SetServer( LPCTSTR lpszServer, int nPort = 700 ); void SetProxy( LPCTSTR lpszProxyServer, int nProxyPort, int nProxyType = PROXYTYPE_HTTP11, LPCTSTR lpszProxyUser = NULL, LPCTSTR lpszProxyPass = NULL ); void SetProxy( QLPROXYINFO &infoProxy ); void SetAppType( CString strAppType ); void SetSessionID( CString strSessionID ); void SetVerifyMD5( CString strVerifyMD5 ); void SetUserSex( long nUerSex ); void SetUserType( long nUserType ); DWORD SignIn( LPCTSTR lpszName, LPCTSTR lpszPassword, LPCTSTR lpszDispName, long lFlag = 0, bool bConnectMastServer = true ); DWORD SignOut(); void OnConnecting( CQLClientSocket *pSocket ); void OnConnected( CQLClientSocket *pSocket ); void OnConnectionClosed( CQLClientSocket *pSocket ); void OnConnectionErr( CQLClientSocket *pSocket, int nErrorCode ); void GetServerInfo( CString &strServer, int &nPort, CString strMethod = _T( "" ) ); CString GetSessionID(); CString GetServerIP(); void GetLifeSpace( int &nLifeSpace ); void RemoveFreeSocket( CQLClientSocket *pSocket ); CQLCommander * GetCommander( CQLClientSocket *pSocket ); void OnLifetime(); BOOL IsThisSessionID( CString strSessionID ); BOOL GetConnection( CQLCommander *pCommander, BOOL bValidate = SOCKET_CHECK_DEFAULT ); void OnSndCmdComplete( CQLRequest *pRequest ); BOOL OnResponse( CQLResponse *pResponse, CQLClientSocket *pSocket ); static DWORD GetTrID(); void FreeConnection( CQLClientSocket *pSocket ); void ValidateConnection( CQLClientSocket *pSocket ); protected: DECLARE_MESSAGE_MAP() void OnChallenges( CQLResponse *pResponse ); void GetQLPROXYINFO( CString &strProxyServer, CString &strProxyUser, CString &strProxyPassword, UINT *puProxyPort ); void CheckageVersion( DWORD dwVersion ); void RemoveAllConnection(); void OnSearchingServer(); BOOL SearchServer(); afx_msg LONG OnFoundServer(WPARAM wParam, LPARAM lParam); afx_msg void OnTimer(UINT nIDEvent); private: void OnSignInMainResponse( CQLResponse *pResponse ); void OnSignInResponse( CQLResponse *pResponse ); void OnErrorResponse( CQLResponse *pResponse ); void OnVerResponse( CQLResponse *pResponse ); };