RakNet  4.0
Public Member Functions | List of all members
RakNet::AutopatcherMySQLRepository Class Reference

#include <AutopatcherMySQLRepository.h>

Inheritance diagram for RakNet::AutopatcherMySQLRepository:
RakNet::AutopatcherRepositoryInterface

Public Member Functions

bool CreateAutopatcherTables (void)
 
bool DestroyAutopatcherTables (void)
 
bool AddApplication (const char *applicationName, const char *userName)
 
bool RemoveApplication (const char *applicationName)
 
bool UpdateApplicationFiles (const char *applicationName, const char *applicationDirectory, const char *userName, FileListProgress *cb)
 
virtual bool GetChangelistSinceDate (const char *applicationName, FileList *addedFiles, FileList *deletedFiles, double sinceDate)
 
virtual bool GetPatches (const char *applicationName, FileList *input, FileList *patchList)
 
virtual bool GetMostRecentChangelistWithPatches (RakNet::RakString &applicationName, FileList *patchedFiles, FileList *updatedFiles, FileList *updatedFileHashes, FileList *deletedFiles, double *priorRowPatchTime, double *mostRecentRowPatchTime)
 
virtual const char * GetLastError (void) const
 If any of the above functions fail, the error string is stored internally. Call this to get it.
 
virtual unsigned int GetFilePart (const char *filename, unsigned int startReadBytes, unsigned int numBytesToRead, void *preallocatedDestination, FileListNodeContext context)
 
virtual const int GetIncrementalReadChunkSize (void) const
 
- Public Member Functions inherited from MySQLInterface
bool Connect (const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag)
 Calls mysql_real_connect with the implicit mySqlConnection.
 
void Disconnect (void)
 Disconnect from the database.
 
bool IsConnected (void) const
 Returns if we are connected to the database.
 
virtual const char * GetLastError (void) const
 If any of the above functions fail, the error string is stored internally. Call this to get it.
 
char * GetLocalTimestamp (void)
 Returns the result of SELECT LOCALTIMESTAMP.
 

Detailed Description

An implementation of the AutopatcherRepositoryInterface to use MySQL to store the relevant data

Member Function Documentation

bool RakNet::AutopatcherMySQLRepository::AddApplication ( const char *  applicationName,
const char *  userName 
)

Add an application for use by files. Call this second.

Parameters
[in]applicationNameA null terminated string.
[in]userNameStored in the database, but otherwise unused. Useful to track who added this application.
Returns
True on success, false on failure.
bool RakNet::AutopatcherMySQLRepository::CreateAutopatcherTables ( void  )

Create the tables used by the autopatcher, for all applications. Call this first.

Returns
True on success, false on failure.
bool RakNet::AutopatcherMySQLRepository::DestroyAutopatcherTables ( void  )

Destroy the tables used by the autopatcher. Don't call this unless you don't want to use the autopatcher anymore, or are testing.

Returns
True on success, false on failure.
virtual bool RakNet::AutopatcherMySQLRepository::GetChangelistSinceDate ( const char *  applicationName,
FileList *  addedFiles,
FileList *  deletedFiles,
double  sinceDate 
)
virtual

Get list of files added and deleted since a certain date. This is used by AutopatcherServer and not usually explicitly called.

Parameters
[in]applicationNameA null terminated string previously passed to AddApplication
[out]addedFilesA list of the current versions of filenames with SHA1_LENGTH byte hashes as their data that were created after sinceData
[out]deletedFilesA list of the current versions of filenames that were deleted after sinceData
[in]Aninput date, in the string format of a timestamp.
Returns
True on success, false on failure.

Implements RakNet::AutopatcherRepositoryInterface.

virtual unsigned int RakNet::AutopatcherMySQLRepository::GetFilePart ( const char *  filename,
unsigned int  startReadBytes,
unsigned int  numBytesToRead,
void *  preallocatedDestination,
FileListNodeContext  context 
)
virtual

Read part of a file into destination Return the number of bytes written. Return 0 when file is done.

Parameters
[in]filenameFilename to read
[in]startReadBytesWhat offset from the start of the file to read from
[in]numBytesToReadHow many bytes to read. This is also how many bytes have been allocated to preallocatedDestination
[out]preallocatedDestinationWrite your data here
Returns
The number of bytes read, or 0 if none
virtual const int RakNet::AutopatcherMySQLRepository::GetIncrementalReadChunkSize ( void  ) const
virtual
Returns
Passed to FileListTransfer::Send() as the _chunkSize parameter.

Implements RakNet::AutopatcherRepositoryInterface.

virtual bool RakNet::AutopatcherMySQLRepository::GetMostRecentChangelistWithPatches ( RakNet::RakString applicationName,
FileList *  patchedFiles,
FileList *  updatedFiles,
FileList *  updatedFileHashes,
FileList *  deletedFiles,
double *  priorRowPatchTime,
double *  mostRecentRowPatchTime 
)
virtual

For the most recent update, return files that were patched, added, or deleted. For files that were patched, return both the patch in patchedFiles and the current version in updatedFiles The cache will be used if the client last patched between priorRowPatchTime and mostRecentRowPatchTime No files changed will be returned to the client if the client last patched after mostRecentRowPatchTime

Parameters
[in,out]applicationNameName 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.
[out]patchedFilesGiven the most recent update, if a file was patched, add it to this list. The context data for each file will be PC_HASH_WITH_PATCH. The first 4 bytes of data should be a hash of the file being patched. The second 4 bytes should be the hash of the file after the patch. The remaining bytes should be the patch itself.
[out]updatedFilesThe current value of the file. List should have the same length and order as patchedFiles
[out]updatedFileHashesThe hash of the current value of the file. List should have the same length and order as patchedFiles
[out]deletedFilesFiles that were deleted in the last patch.
[out]priorRowPatchTimeWhen the patch before the most recent patch took place. 0 means never.
[out]mostRecentRowPatchTimeWhen the most recent patch took place. 0 means never.
Returns
true on success, false on failure

Implements RakNet::AutopatcherRepositoryInterface.

virtual bool RakNet::AutopatcherMySQLRepository::GetPatches ( const char *  applicationName,
FileList *  input,
FileList *  patchList 
)
virtual

Get patches (or files) for every file in input, assuming that input has a hash for each of those files. This is used by AutopatcherServer and not usually explicitly called.

Parameters
[in]applicationNameA null terminated string previously passed to AddApplication
[in]inputA list of files with hashes to get from the database. If this hash exists, a patch to the current version is returned if this file is not the current version. Otherwise the current version is returned.
[out]patchListA list of files with either the filedata or the patch. This is a subset of 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
Returns
True on success, false on failure.

Implements RakNet::AutopatcherRepositoryInterface.

bool RakNet::AutopatcherMySQLRepository::RemoveApplication ( const char *  applicationName)

Remove an application and files used by that application.

Parameters
[in]applicationNameA null terminated string previously passed to AddApplication
Returns
True on success, false on failure.
bool RakNet::AutopatcherMySQLRepository::UpdateApplicationFiles ( const char *  applicationName,
const char *  applicationDirectory,
const char *  userName,
FileListProgress cb 
)

Update all the files for an application to match what is at the specified directory. Call this third. Be careful not to call this with the wrong directory. This is implemented in a Begin and Rollback block so you won't a messed up database from get partial updates.

Parameters
[in]applicationNameA null terminated string previously passed to AddApplication
[in]applicationDirectoryThe base directory of your application. All files in this directory and subdirectories are added.
[in]userNameStored in the database, but otherwise unused. Useful to track who added this revision
[in]cbCallback to get progress updates. Pass 0 to not use.
Returns
True on success, false on failure.

The documentation for this class was generated from the following file: