SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SLNet::DirectoryDeltaTransfer Class Reference

`#include <slikenet/DirectoryDeltaTransfer.h>`

Inheritance diagram for SLNet::DirectoryDeltaTransfer:

## Public Member Functions

| DirectoryDeltaTransfer ()
virtual | ~DirectoryDeltaTransfer ()
void | SetFileListTransferPlugin (FileListTransfer *flt)
| This plugin has a dependency on the FileListTransfer plugin, which it uses to actually send the files.
void | SetApplicationDirectory (const char *pathToApplication)
| Set the local root directory to base all file uploads and downloads off of.
void | SetUploadSendParameters (PacketPriority _priority, char _orderingChannel)
| What parameters to use for the RakPeerInterface::Send() call when uploading files.
void | AddUploadsFromSubdirectory (const char *subdir)
| Add all files in the specified subdirectory recursively.
unsigned short | DownloadFromSubdirectory (const char *subdir, const char *outputSubdir, bool prependAppDirToOutputSubdir, SystemAddress host, FileListTransferCBInterface *onFileCallback, PacketPriority _priority, char _orderingChannel, FileListProgress *cb)
| Downloads files from the matching parameter subdir in AddUploadsFromSubdirectory.
unsigned short | DownloadFromSubdirectory (FileList &localFiles, const char *subdir, const char *outputSubdir, bool prependAppDirToOutputSubdir, SystemAddress host, FileListTransferCBInterface *onFileCallback, PacketPriority _priority, char _orderingChannel, FileListProgress *cb)
| Downloads files from the matching parameter subdir in AddUploadsFromSubdirectory.
void | GenerateHashes (FileList &localFiles, const char *outputSubdir, bool prependAppDirToOutputSubdir)
void | ClearUploads (void)
| Clear all allowed uploads previously set with AddUploadsFromSubdirectory.
unsigned | GetNumberOfFilesForUpload (void) const
| Returns how many files are available for upload.
void | SetDownloadRequestIncrementalReadInterface (IncrementalReadInterface *_incrementalReadInterface, unsigned int _chunkSize)
| Normally, if a remote system requests files, those files are all loaded into memory and sent immediately.
virtual PluginReceiveResult | OnReceive (Packet *packet)
Public Member Functions inherited from SLNet::PluginInterface2
| PluginInterface2 ()
virtual | ~PluginInterface2 ()
virtual void | OnAttach (void)
| Called when the interface is attached.
virtual void | OnDetach (void)
| Called when the interface is detached.
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual void | OnRakPeerStartup (void)
| Called when RakPeer is initialized.
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
virtual bool | UsesReliabilityLayer (void) const
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
RakPeerInterface * | GetRakPeerInterface (void) const
RakNetGUID | GetMyGUIDUnified (void) const
void | SetRakPeerInterface (RakPeerInterface *ptr)
void | SetTCPInterface (TCPInterface *ptr)

## Protected Member Functions

void | OnDownloadRequest (Packet *packet)
Protected Member Functions inherited from SLNet::PluginInterface2
void | SendUnified (const SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
void | SendUnified (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | SendListUnified (const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
Packet * | AllocatePacketUnified (unsigned dataSize)
void | PushBackPacketUnified (Packet *packet, bool pushAtHead)
void | DeallocPacketUnified (Packet *packet)

## Protected Attributes

char | applicationDirectory [512]
FileListTransfer * | fileListTransfer
FileList * | availableUploads
PacketPriority | priority
char | orderingChannel
IncrementalReadInterface * | incrementalReadInterface
unsigned int | chunkSize
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

## Detailed Description

Definition at line 69 of file DirectoryDeltaTransfer.h.

## Constructor & Destructor Documentation

SLNet::DirectoryDeltaTransfer::DirectoryDeltaTransfer | ( |  | ) |

virtual SLNet::DirectoryDeltaTransfer::~DirectoryDeltaTransfer | ( |  | ) |

virtual

## Member Function Documentation

void SLNet::DirectoryDeltaTransfer::AddUploadsFromSubdirectory | ( | const char * | subdir | ) |

Add all files in the specified subdirectory recursively.

subdir is appended to pathToApplication in SetApplicationDirectory(). All files in the resultant directory and subdirectories are then hashed so that users can download them.

Precondition
  You must call SetFileListTransferPlugin with a valid FileListTransfer plugin

Parameters

  [in] | subdir | Concatenated with pathToApplication to form the final path from which to allow uploads.

void SLNet::DirectoryDeltaTransfer::ClearUploads | ( | void |  | ) |

Clear all allowed uploads previously set with AddUploadsFromSubdirectory.

unsigned short SLNet::DirectoryDeltaTransfer::DownloadFromSubdirectory | ( | const char * | subdir,
|  | const char * | outputSubdir,
|  | bool | prependAppDirToOutputSubdir,
|  | SystemAddress | host,
|  | FileListTransferCBInterface * | onFileCallback,
|  | PacketPriority | _priority,
|  | char | _orderingChannel,
|  | FileListProgress * | cb
| ) |  |

Downloads files from the matching parameter subdir in AddUploadsFromSubdirectory.

subdir must contain all starting characters in subdir in AddUploadsFromSubdirectory Therefore, AddUploadsFromSubdirectory("Levels/Level1/"); would allow you to download using DownloadFromSubdirectory("Levels/Level1/Textures/"... but it would NOT allow you to download from DownloadFromSubdirectory("Levels/"... or DownloadFromSubdirectory("Levels/Level2/"...

Precondition
  You must call SetFileListTransferPlugin with a valid FileListTransfer plugin

Note
  Blocking. Will block while hashes of the local files are generated

Parameters

  [in] | subdir | A directory passed to AddUploadsFromSubdirectory on the remote system. The passed dir can be more specific than the remote dir.
  [in] | outputSubdir | The directory to write the output to. Usually this will match subdir but it can be different if you want.
  [in] | prependAppDirToOutputSubdir | True to prepend outputSubdir with pathToApplication when determining the final output path. Usually you want this to be true.
  [in] | host | The address of the remote system to send the message to.
  [in] | onFileCallback | Callback to call per-file (optional). When fileIndex+1==setCount in the callback then the download is done
  [in] | _priority | See RakPeerInterface::Send()
  [in] | _orderingChannel | See RakPeerInterface::Send()
  [in] | cb | Callback to get progress updates. Pass 0 to not use.

Returns
  A set ID, identifying this download set. Returns 65535 on host unreachable.

unsigned short SLNet::DirectoryDeltaTransfer::DownloadFromSubdirectory | ( | FileList & | localFiles,
|  | const char * | subdir,
|  | const char * | outputSubdir,
|  | bool | prependAppDirToOutputSubdir,
|  | SystemAddress | host,
|  | FileListTransferCBInterface * | onFileCallback,
|  | PacketPriority | _priority,
|  | char | _orderingChannel,
|  | FileListProgress * | cb
| ) |  |

Downloads files from the matching parameter subdir in AddUploadsFromSubdirectory.

subdir must contain all starting characters in subdir in AddUploadsFromSubdirectory Therefore, AddUploadsFromSubdirectory("Levels/Level1/"); would allow you to download using DownloadFromSubdirectory("Levels/Level1/Textures/"... but it would NOT allow you to download from DownloadFromSubdirectory("Levels/"... or DownloadFromSubdirectory("Levels/Level2/"...

Precondition
  You must call SetFileListTransferPlugin with a valid FileListTransfer plugin

Note
  Nonblocking, but requires call to GenerateHashes()

Parameters

  [in] | localFiles | Hashes of local files already on the harddrive. Populate with GenerateHashes(), which you may wish to call from a thread
  [in] | subdir | A directory passed to AddUploadsFromSubdirectory on the remote system. The passed dir can be more specific than the remote dir.
  [in] | outputSubdir | The directory to write the output to. Usually this will match subdir but it can be different if you want.
  [in] | prependAppDirToOutputSubdir | True to prepend outputSubdir with pathToApplication when determining the final output path. Usually you want this to be true.
  [in] | host | The address of the remote system to send the message to.
  [in] | onFileCallback | Callback to call per-file (optional). When fileIndex+1==setCount in the callback then the download is done
  [in] | _priority | See RakPeerInterface::Send()
  [in] | _orderingChannel | See RakPeerInterface::Send()
  [in] | cb | Callback to get progress updates. Pass 0 to not use.

Returns
  A set ID, identifying this download set. Returns 65535 on host unreachable.

void SLNet::DirectoryDeltaTransfer::GenerateHashes | ( | FileList & | localFiles,
|  | const char * | outputSubdir,
|  | bool | prependAppDirToOutputSubdir
| ) |  |

Hash files already on the harddrive, in preparation for a call to DownloadFromSubdirectory(). Passed to second version of DownloadFromSubdirectory() This is slow, and it is exposed so you can call it from a thread before calling DownloadFromSubdirectory()

Parameters

  [out] | localFiles | List of hashed files populated from outputSubdir and prependAppDirToOutputSubdir
  [in] | outputSubdir | The directory to write the output to. Usually this will match subdir but it can be different if you want.
  [in] | prependAppDirToOutputSubdir | True to prepend outputSubdir with pathToApplication when determining the final output path. Usually you want this to be true.

unsigned SLNet::DirectoryDeltaTransfer::GetNumberOfFilesForUpload | ( | void |  | ) | const

Returns how many files are available for upload.

Returns
  How many files are available for upload

void SLNet::DirectoryDeltaTransfer::OnDownloadRequest | ( | Packet * | packet | ) |

protected

virtual PluginReceiveResult SLNet::DirectoryDeltaTransfer::OnReceive | ( | Packet * | packet | ) |

virtual

OnReceive is called for every packet.

Parameters

  [in] | packet | the packet that is being returned to the user

Returns
  True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from SLNet::PluginInterface2.

void SLNet::DirectoryDeltaTransfer::SetApplicationDirectory | ( | const char * | pathToApplication | ) |

Set the local root directory to base all file uploads and downloads off of.

Parameters

  [in] | pathToApplication | This path will be prepended to applicationSubdirectory in AddUploadsFromSubdirectory to find the actual path on disk.

void SLNet::DirectoryDeltaTransfer::SetDownloadRequestIncrementalReadInterface | ( | IncrementalReadInterface * | _incrementalReadInterface,
|  | unsigned int | _chunkSize
| ) |  |

Normally, if a remote system requests files, those files are all loaded into memory and sent immediately.

This function allows the files to be read in incremental chunks, saving memory

Parameters

  [in] | _incrementalReadInterface | If a file in fileList has no data, filePullInterface will be used to read the file in chunks of size chunkSize
  [in] | _chunkSize | How large of a block of a file to send at once

void SLNet::DirectoryDeltaTransfer::SetFileListTransferPlugin | ( | FileListTransfer * | flt | ) |

This plugin has a dependency on the FileListTransfer plugin, which it uses to actually send the files.

So you need an instance of that plugin registered with RakPeerInterface, and a pointer to that interface should be passed here.

Parameters

  [in] | flt | A pointer to a registered instance of FileListTransfer

void SLNet::DirectoryDeltaTransfer::SetUploadSendParameters | ( | PacketPriority | _priority,
|  | char | _orderingChannel
| ) |  |

What parameters to use for the RakPeerInterface::Send() call when uploading files.

Parameters

  [in] | _priority | See RakPeerInterface::Send()
  [in] | _orderingChannel | See RakPeerInterface::Send()

## Member Data Documentation

char SLNet::DirectoryDeltaTransfer::applicationDirectory[512]

protected

Definition at line 164 of file DirectoryDeltaTransfer.h.

FileList* SLNet::DirectoryDeltaTransfer::availableUploads

protected

Definition at line 166 of file DirectoryDeltaTransfer.h.

unsigned int SLNet::DirectoryDeltaTransfer::chunkSize

protected

Definition at line 170 of file DirectoryDeltaTransfer.h.

FileListTransfer* SLNet::DirectoryDeltaTransfer::fileListTransfer

protected

Definition at line 165 of file DirectoryDeltaTransfer.h.

IncrementalReadInterface* SLNet::DirectoryDeltaTransfer::incrementalReadInterface

protected

Definition at line 169 of file DirectoryDeltaTransfer.h.

char SLNet::DirectoryDeltaTransfer::orderingChannel

protected

Definition at line 168 of file DirectoryDeltaTransfer.h.

PacketPriority SLNet::DirectoryDeltaTransfer::priority

protected

Definition at line 167 of file DirectoryDeltaTransfer.h.

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

- Source/include/slikenet/DirectoryDeltaTransfer.h