AutopatcherRepositoryInterface.h 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. ///
  11. /// \file AutopatcherRepositoryInterface.h
  12. /// \brief An interface used by AutopatcherServer to get the data necessary to run an autopatcher.
  13. ///
  14. #ifndef __AUTOPATCHER_REPOSITORY_INTERFACE_H
  15. #define __AUTOPATCHER_REPOSITORY_INTERFACE_H
  16. #include "IncrementalReadInterface.h"
  17. #include "SimpleMutex.h"
  18. namespace RakNet
  19. {
  20. /// Forward declarations
  21. class FileList;
  22. class BitStream;
  23. /// An interface used by AutopatcherServer to get the data necessary to run an autopatcher. This is up to you to implement for custom repository solutions.
  24. class AutopatcherRepositoryInterface : public IncrementalReadInterface
  25. {
  26. public:
  27. /// Get list of files added and deleted since a certain date. This is used by AutopatcherServer and not usually explicitly called.
  28. /// \param[in] applicationName A null terminated string identifying the application
  29. /// \param[out] addedFiles A list of the current versions of filenames with hashes as their data that were created after \a sinceData
  30. /// \param[out] deletedFiles A list of the current versions of filenames that were deleted after \a sinceData
  31. /// \param[in] An input date, in whatever format your repository uses
  32. /// \param[out] currentDate The current server date, in whatever format your repository uses
  33. /// \return True on success, false on failure.
  34. virtual bool GetChangelistSinceDate(const char *applicationName, FileList *addedOrModifiedFilesWithHashData, FileList *deletedFiles, double sinceDate)=0;
  35. /// Get patches (or files) for every file in input, assuming that input has a hash for each of those files.
  36. /// \param[in] applicationName A null terminated string identifying the application
  37. /// \param[in] input A list of files with SHA1_LENGTH byte hashes to get from the database.
  38. /// \param[out] patchList You should return list of files with either the filedata or the patch. This is a subset of \a input. The context data for each file will be either PC_WRITE_FILE (to just write the file) or PC_HASH_WITH_PATCH (to patch). If PC_HASH_WITH_PATCH, then the file contains a SHA1_LENGTH byte patch followed by the hash. The datalength is patchlength + SHA1_LENGTH
  39. /// \param[out] currentDate The current server date, in whatever format your repository uses
  40. /// \return 1 on success, 0 on database failure, -1 on tried to download original unmodified file
  41. virtual int GetPatches(const char *applicationName, FileList *input, bool allowDownloadOfOriginalUnmodifiedFiles, FileList *patchList)=0;
  42. /// For the most recent update, return files that were patched, added, or deleted. For files that were patched, return both the patch in \a patchedFiles and the current version in \a updatedFiles
  43. /// \param[in,out] applicationName Name of the application to get patches for. If empty, uses the most recently updated application, and the string will be updated to reflect this name.
  44. /// \param[out] patchedFiles A list of patched files with op PC_HASH_2_WITH_PATCH. It has 2 hashes, the priorHash and the currentHash. The currentHash is checked on the client after patching for patch success. The priorHash is checked in AutopatcherServer::OnGetPatch() to see if the client is able to hash with the version they currently have
  45. /// \param[out] patchedFiles A list of new files. It contains the actual data in addition to the filename
  46. /// \param[out] addedOrModifiedFileHashes A list of file hashes that were either modified or new. This is returned to the client when replying to ID_AUTOPATCHER_CREATION_LIST, which tells the client what files have changed on the server since a certain date
  47. /// \param[out] deletedFiles A list of the current versions of filenames that were deleted in the most recent patch
  48. /// \param[out] whenPatched time in seconds since epoch when patched. Use time() function to get this in C
  49. /// \return true on success, false on failure
  50. virtual bool GetMostRecentChangelistWithPatches(
  51. RakNet::RakString &applicationName,
  52. FileList *patchedFiles,
  53. FileList *updatedFiles,
  54. FileList *addedOrModifiedFileHashes,
  55. FileList *deletedFiles,
  56. double *priorRowPatchTime,
  57. double *mostRecentRowPatchTime)=0;
  58. /// \return Whatever this function returns is sent from the AutopatcherServer to the AutopatcherClient when one of the above functions returns false.
  59. virtual const char *GetLastError(void) const=0;
  60. /// \return Passed to FileListTransfer::Send() as the _chunkSize parameter.
  61. virtual const int GetIncrementalReadChunkSize(void) const=0;
  62. };
  63. } // namespace RakNet
  64. #endif
粤ICP备19079148号