AutoPatcher Class Reference

Autopatcher Subsystem. More...

#include <Autopatcher.h>

List of all members.

Public Member Functions

 AutoPatcher ()
 Default Constructor.
 ~AutoPatcher ()
 Destructor.
void Clear (void)
void SetOrderingStream (int streamIndex)
void SetNetworkingSystem (RakPeerInterface *localSystem)
void SetNetworkingSystem (RakClientInterface *localSystem)
void SetNetworkingSystem (RakServerInterface *localSystem)
void SetCompressionBoundary (unsigned boundary)
SetFileDownloadableResult SetFileDownloadable (char *filename, bool checkFileSignature)
bool UnsetFileDownloadable (char *filename)
unsigned int GetDownloadStatus (char *filename, unsigned *fileLength, bool *fileDataIsCompressed, unsigned *compressedFileLength)
void SetDownloadedFileDirectoryPrefix (char *prefix)
void RequestDownloadableFileList (const PlayerID remoteSystem)
void SendDownloadableFileList (const PlayerID remoteSystem)
void OnAutopatcherFileList (Packet *packet, bool onlyAcceptFilesIfRequested)
void OnAutopatcherRequestFiles (Packet *packet)
void OnAutopatcherSetDownloadList (Packet *packet)
bool OnAutopatcherWriteFile (Packet *packet)

Static Public Member Functions

static bool CreateFileSignature (char *filename)
static bool GenerateSHA1 (char *filename, char SHA1Code[SHA1_LENGTH])
static int GetFileLength (char *filename)
static bool WriteFileWithDirectories (const char *path, char *data, unsigned dataLength)

Protected Attributes

RakPeerInterfacerakPeerInterface
 One of these 3 must be set in order to send data.
RakClientInterfacerakClientInterface
 One of these 3 must be set in order to send data.
RakServerInterfacerakServerInterface
 One of these 3 must be set in order to send data.
char * downloadPrefix
 The directory to download into basically.
unsigned compressionBoundary
 Files of length >= this will be compressed.
bool downloadableFilesRequested
 true if the downloadableFiles have been requested
int orderingStream
 The ordering stream to use.
DataStructures::List< DownloadableFileDescriptor * > downloadableFiles
 Directory of files that are downloadable.
DataStructures::List< DownloadableFileDescriptor * > downloadingFiles


Detailed Description

Autopatcher Subsystem.

The autopatcher will update client files to match a given server fileset. Files are transferred compressed. This is a system on top of RakNet that is here for the convenience of users.


Member Function Documentation

void AutoPatcher::Clear void   ) 
 

Frees all downloadable files. Frees the download directory prefix.

bool AutoPatcher::CreateFileSignature char *  filename  )  [static]
 

Creates a .sha file signature for a particular file. This is used by SetFileDownloadable with checkFileSignature as true

Parameters:
[in] filename the name of the file
Returns:
true on success, false on file does not exist.

unsigned int AutoPatcher::GetDownloadStatus char *  filename,
unsigned *  fileLength,
bool *  fileDataIsCompressed,
unsigned *  compressedFileLength
 

Returns how many files are still in the download list.

Precondition:
Requires a previous call to OnAutopatcherFileList If returns >=1 filename and fileLength will be filled in to match the current file being downloaded A value of 0 for compressedFileLength indicates unknown
Parameters:
[in] filename the file currently downloaded
[in] fileLength the size of the file currently downloaded
[in] fileDataIsCompressed true if the file is compressed
[in] compressedFileLength the size of the compressed file
Returns:
The number of files still in the download list.

void AutoPatcher::OnAutopatcherFileList Packet packet,
bool  onlyAcceptFilesIfRequested
 

If the packet identifier is ID_AUTOPATCHER_FILE_LIST, call this function with the packet. It will parse out all the files on the remote system and request to download the ones we don't have or don't match. The remote system should get a packet with ID ID_AUTOPATCHER_REQUEST_FILES for each file requested We can specify to only accept files if we previously requested them by a call to RequestDownloadableFileList. Set onlyAcceptFilesIfRequested to true to do this After this function is called you can call GetDownloadStatus(...) To find out which, if any, files are currently downloading

Parameters:
[in] packet the packet with id ID_AUTOPATCHER_FILE_LIST
[in] onlyAcceptFilesIfRequested Does what the name says. This means the server won't push files to you - you have to ask for them first.

void AutoPatcher::OnAutopatcherRequestFiles Packet packet  ) 
 

If the packet identifier is ID_AUTOPATCHER_REQUEST_FILES, call this function with the packet. Reads the files from disk and sends them to the specified system

Parameters:
[in] packet the packet with id ID_AUTOPATCHER_REQUEST_FILES

void AutoPatcher::OnAutopatcherSetDownloadList Packet packet  ) 
 

If the packet identifier is ID_AUTOPATCHER_SET_DOWNLOAD_LIST, call this function with the packet. Finalizes the list of files that will be downloaded.

Parameters:
[in] packet the packet with id ID_AUTOPATCHER_SET_DOWNLOAD_LIST

bool AutoPatcher::OnAutopatcherWriteFile Packet packet  ) 
 

If the packet identifier is ID_AUTOPATCHER_WRITE_FILE, call this function with the packet. Writes a file to disk. There is security to prevent writing files we didn't ask for

Parameters:
[in] packet the packet with id ID_AUTOPATCHER_WRITE_FILE
Returns:
true on success

void AutoPatcher::RequestDownloadableFileList const PlayerID  remoteSystem  ) 
 

Requests that the remote system send the directory of files that are downloadable. The remote system should get ID_AUTOPATCHER_REQUEST_FILE_LIST. When it does, it should call SendDownloadableFileList with the playerID of the sender. For the client, you can put UNASSIGNED_PLAYER_ID for remoteSystem

Parameters:
[in] remoteSystem The remoteSystem to ask for its downloadable file list.

void AutoPatcher::SendDownloadableFileList const PlayerID  remoteSystem  ) 
 

If the packet identifier is ID_AUTOPATCHER_REQUEST_FILE_LIST, call this function with packet->playerID Sends a list of all downloadable files to the remote system The remote system should get a packet with ID ID_AUTOPATCHER_FILE_LIST. When it does, it should call OnAutopatcherFileList with the packet from the network

Parameters:
[in] remoteSystem the player to send the list to.

void AutoPatcher::SetCompressionBoundary unsigned  boundary  ) 
 

Set the value at which files larger than this will be compressed. Files smaller than this will not be compressed. Defaults to 1024. Only changes files later passed to SetFileDownloadable, not files already processed

Parameters:
[in] boundary the new boundary for compression activation.

void AutoPatcher::SetDownloadedFileDirectoryPrefix char *  prefix  ) 
 

Sets a base directory to look for and put all downloaded files in. For example, "Downloads"

Parameters:
prefix the path to the source or the destination directory.

SetFileDownloadableResult AutoPatcher::SetFileDownloadable char *  filename,
bool  checkFileSignature
 

Makes a file downloadable Returns checkFileSignature - if true then check the associated .sha1 to make sure it describes our file. checkFileSignature is useful to make sure a file wasn't externally modified by a hacker or a virus

Parameters:
[in] filename the name of the file
[in] checkFileSignature if true then check the associated .sha1 to make sure it describes our file. checkFileSignature is useful to make sure a file wasn't externally modified by a hacker or a virus. Useful for servers that run a long time.
Returns:
See SetFileDownloadableResult

void AutoPatcher::SetNetworkingSystem RakServerInterface localSystem  ) 
 

Set which instance of RakServerInterface to use for sends. Mutually exclusive with the other 2 overloads.

Parameters:
[in] localSystem The instance of RakServerInterface

void AutoPatcher::SetNetworkingSystem RakClientInterface localSystem  ) 
 

Set which instance of RakClientInterface to use for sends. Mutually exclusive with the other 2 overloads.

Parameters:
[in] localSystem The instance of RakClientInterface

void AutoPatcher::SetNetworkingSystem RakPeerInterface localSystem  ) 
 

Set which instance of RakPeerInterface to use for sends. Mutually exclusive with the other 2 overloads.

Parameters:
[in] localSystem The instance of RakPeerInterface

void AutoPatcher::SetOrderingStream int  streamIndex  ) 
 

Set the ordering stream to send data on. Defaults to 0. Set this if you use ordered data for your game and don't want to hold up game data because of autopatcher file data

Parameters:
[in] streamIndex The stream to use for autopatcher file data. Same thing as the ordering stream for RakPeer::Send

bool AutoPatcher::UnsetFileDownloadable char *  filename  ) 
 

Removes access to a file previously set as downloadable.

Parameters:
[in] filename The name of the file
Returns:
true on success, false on failure.


The documentation for this class was generated from the following files:
Generated on Wed May 3 09:11:54 2006 for RakNet by  doxygen 1.4.6-NO