Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //----------------------------------------------------------------------------------------
  4. #ifndef SESSIONINFODOWNLOADER_H
  5. #define SESSIONINFODOWNLOADER_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "basethinker.h"
  11. #include "cl_downloader.h"
  12. //----------------------------------------------------------------------------------------
  13. class CHttpDownloader;
  14. class CBaseRecordingSession;
  15. //----------------------------------------------------------------------------------------
  16. class CSessionInfoDownloader : public CBaseThinker,
  17. public IDownloadHandler
  18. {
  19. public:
  20. CSessionInfoDownloader();
  21. ~CSessionInfoDownloader();
  22. void CleanupDownloader();
  23. void DownloadSessionInfoAndUpdateBlocks( CBaseRecordingSession *pSession );
  24. bool IsDone() const { return m_bDone; }
  25. bool CanDelete() const { return m_pDownloader == NULL; }
  26. enum ServerSessionInfoError_t
  27. {
  28. ERROR_NONE, // No error
  29. ERROR_NOT_ENOUGH_DATA, // The session info file wasn't even big enough to read a header
  30. ERROR_BAD_NUM_BLOCKS, // The "nb" field either didn't exist or was invalid - there should always been at least one block by the time we're downloading
  31. ERROR_REPLAY_NOT_FOUND, // The server index was downloaded but the replay was not found
  32. ERROR_INVALID_REPLAY_STATUS, // The server index was downloaded and the replay was found, but it had an invalid status
  33. ERROR_INVALID_ORDER, // The server index was downloaded and the replay was found, but it had an invalid reconstruction order (-1)
  34. ERROR_NO_SESSION_NAME, // No session name for entry
  35. ERROR_UNKNOWN_SESSION, // The session info file points to a session (via its name) that the client doesn't know about
  36. ERROR_DOWNLOAD_FAILED, // The session file failed to download
  37. ERROR_BLOCK_READ_FAILED, // Failed to read a block - most likely an overflow
  38. ERROR_COULD_NOT_CREATE_COMPRESSOR, // Could not create the ICompressor to decompress the payload
  39. ERROR_INVALID_UNCOMPRESSED_SIZE, // Uncompressed size was not large enough to read at least one block
  40. ERROR_PAYLOAD_DECOMPRESS_FAILED, // Decompression of the payload failed
  41. ERROR_PAYLOAD_HASH_FAILED, // Used MD5 digest from header on payload and failed
  42. };
  43. ServerSessionInfoError_t m_nError;
  44. HTTPError_t m_nHttpError;
  45. private:
  46. //
  47. // CBaseThinker
  48. //
  49. float GetNextThinkTime() const;
  50. void Think();
  51. //
  52. // IDownloadHandler
  53. //
  54. virtual void OnConnecting( CHttpDownloader *pDownloader ) {}
  55. virtual void OnFetch( CHttpDownloader *pDownloader ) {}
  56. virtual void OnDownloadComplete( CHttpDownloader *pDownloader, const unsigned char *pData );
  57. const char *GetErrorString( int nError, HTTPError_t nHttpError ) const;
  58. const CBaseRecordingSession *m_pSession;
  59. CHttpDownloader *m_pDownloader;
  60. bool m_bDone;
  61. float m_flLastDownloadTime;
  62. };
  63. //----------------------------------------------------------------------------------------
  64. #endif // SESSIONINFODOWNLOADER_H