SLikeNet 0.1.3

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes
FileListTransfer
Plugins

A plugin to provide a simple way to compress and incrementally send the files in the FileList structure. More...

## Classes

class | SLNet::FileListTransfer
| A plugin to provide a simple way to compress and incrementally send the files in the FileList structure. More...
struct | SLNet::FileListTransfer::FileToPush
struct | SLNet::FileListTransfer::FileToPushRecipient
struct | SLNet::FileListTransfer::ThreadData

## Detailed Description

A plugin to provide a simple way to compress and incrementally send the files in the FileList structure.

## Class Documentation

class SLNet::FileListTransfer

A plugin to provide a simple way to compress and incrementally send the files in the FileList structure.

Similar to the DirectoryDeltaTransfer plugin, except that it doesn't send deltas based on pre-existing files or actually write the files to disk.

Usage: Call SetupReceive to allow one file set to arrive. The value returned by FileListTransfer::SetupReceive()
is the setID that is allowed.
It's up to you to transmit this value to the other system, along with information indicating what kind of files you want to get.
The other system should then prepare a FileList and call FileListTransfer::Send(), passing the return value of FileListTransfer::SetupReceive()
as the setID parameter to FileListTransfer::Send()

Definition at line 62 of file FileListTransfer.h.

Inheritance diagram for SLNet::FileListTransfer:

### Public Member Functions

| FileListTransfer ()
virtual | ~FileListTransfer ()
void | StartIncrementalReadThreads (int numThreads, int threadPriority=-99999)
| Optionally start worker threads when using _incrementalReadInterface for the Send() operation.
unsigned short | SetupReceive (FileListTransferCBInterface *handler, bool deleteHandler, SystemAddress allowedSender)
| Allows one corresponding Send() call from another system to arrive.
void | Send (FileList *fileList, SLNet::RakPeerInterface *rakPeer, SystemAddress recipient, unsigned short setID, PacketPriority priority, char orderingChannel, IncrementalReadInterface *_incrementalReadInterface=0, unsigned int _chunkSize=262144 *4 *16)
| Send the FileList structure to another system, which must have previously called SetupReceive().
unsigned int | GetPendingFilesToAddress (SystemAddress recipient)
| Return number of files waiting to go out to a particular address.
void | CancelReceive (unsigned short inSetId)
| Stop a download.
void | RemoveReceiver (SystemAddress systemAddress)
| Remove all handlers associated with a particular system address.
bool | IsHandlerActive (unsigned short inSetId)
| Is a handler passed to SetupReceive still running?
void | AddCallback (FileListProgress *cb)
| Adds a callback to get progress reports about what the file list instances do.
void | RemoveCallback (FileListProgress *cb)
| Removes a callback.
void | ClearCallbacks (void)
| Removes all callbacks.
void | GetCallbacks (DataStructures::List< FileListProgress * > &callbacks)
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | Update (void)
| Update is called every time a packet is checked for .
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 | OnRakPeerStartup (void)
| Called when RakPeer is initialized.
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

bool | DecodeSetHeader (Packet *packet)
bool | DecodeFile (Packet *packet, bool fullFile)
void | Clear (void)
void | OnReferencePush (Packet *packet, bool fullFile)
void | OnReferencePushAck (Packet *packet)
void | SendIRIToAddress (SystemAddress systemAddress, unsigned short inSetId)
void | RemoveFromList (FileToPushRecipient *ftpr)
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

DataStructures::Map< unsigned short, FileListReceiver * > | fileListReceivers
unsigned short | setId
DataStructures::List < FileListProgress * > | fileListProgressCallbacks
DataStructures::List < FileToPushRecipient * > | fileToPushRecipientList
SimpleMutex | fileToPushRecipientListMutex
ThreadPool< ThreadData, int > | threadPool
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

### Friends

int | SendIRIToAddressCB (FileListTransfer::ThreadData threadData, bool *returnOutput, void *perThreadData)

#### Constructor & Destructor Documentation

SLNet::FileListTransfer::FileListTransfer | ( |  | ) |

virtual SLNet::FileListTransfer::~FileListTransfer | ( |  | ) |

virtual

#### Member Function Documentation

void SLNet::FileListTransfer::AddCallback | ( | FileListProgress * | cb | ) |

Adds a callback to get progress reports about what the file list instances do.

Parameters

  [in] | cb | A pointer to an externally defined instance of FileListProgress. This pointer is held internally, so should remain valid as long as this class is valid.

void SLNet::FileListTransfer::CancelReceive | ( | unsigned short | inSetId | ) |

Stop a download.

void SLNet::FileListTransfer::Clear | ( | void |  | ) |

protected

void SLNet::FileListTransfer::ClearCallbacks | ( | void |  | ) |

Removes all callbacks.

bool SLNet::FileListTransfer::DecodeFile | ( | Packet * | packet,
|  | bool | fullFile
| ) |  |

protected

bool SLNet::FileListTransfer::DecodeSetHeader | ( | Packet * | packet | ) |

protected

void SLNet::FileListTransfer::GetCallbacks | ( | DataStructures::List< FileListProgress * > & | callbacks | ) |

Returns all callbacks added with AddCallback()

Parameters

  [out] | callbacks | The list is set to the list of callbacks

unsigned int SLNet::FileListTransfer::GetPendingFilesToAddress | ( | SystemAddress | recipient | ) |

Return number of files waiting to go out to a particular address.

bool SLNet::FileListTransfer::IsHandlerActive | ( | unsigned short | inSetId | ) |

Is a handler passed to SetupReceive still running?

virtual void SLNet::FileListTransfer::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

virtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters

  [in] | systemAddress | The system whose connection was closed
  [in] | rakNetGuid | The guid of the specified system
  [in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from SLNet::PluginInterface2.

virtual void SLNet::FileListTransfer::OnRakPeerShutdown | ( | void |  | ) |

virtual

Called when RakPeer is shutdown.

Reimplemented from SLNet::PluginInterface2.

virtual PluginReceiveResult SLNet::FileListTransfer::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::FileListTransfer::OnReferencePush | ( | Packet * | packet,
|  | bool | fullFile
| ) |  |

protected

void SLNet::FileListTransfer::OnReferencePushAck | ( | Packet * | packet | ) |

protected

void SLNet::FileListTransfer::RemoveCallback | ( | FileListProgress * | cb | ) |

Removes a callback.

Parameters

  [in] | cb | A pointer to an externally defined instance of FileListProgress that was previously added with AddCallback()

void SLNet::FileListTransfer::RemoveFromList | ( | FileToPushRecipient * | ftpr | ) |

protected

void SLNet::FileListTransfer::RemoveReceiver | ( | SystemAddress | systemAddress | ) |

Remove all handlers associated with a particular system address.

void SLNet::FileListTransfer::Send | ( | FileList * | fileList,
|  | SLNet::RakPeerInterface * | rakPeer,
|  | SystemAddress | recipient,
|  | unsigned short | setID,
|  | PacketPriority | priority,
|  | char | orderingChannel,
|  | IncrementalReadInterface * | _incrementalReadInterface = `0`,
|  | unsigned int | _chunkSize = `262144 *4 *16`
| ) |  |

Send the FileList structure to another system, which must have previously called SetupReceive().

Parameters

  [in] | fileList | A list of files. The data contained in FileList::data will be sent incrementally and compressed among all files in the set
  [in] | rakPeer | The instance of RakNet to use to send the message. Pass 0 to use the instance the plugin is attached to
  [in] | recipient | The address of the system to send to
  [in] | setID | The return value of SetupReceive() which was previously called on recipient
  [in] | priority | Passed to RakPeerInterface::Send()
  [in] | orderingChannel | Passed to RakPeerInterface::Send()
  [in] | _incrementalReadInterface | If a file in fileList has no data, _incrementalReadInterface will be used to read the file in chunks of size chunkSize
  [in] | _chunkSize | How large of a block of a file to read/send at once. Large values use more memory but transfer slightly faster.

void SLNet::FileListTransfer::SendIRIToAddress | ( | SystemAddress | systemAddress,
|  | unsigned short | inSetId
| ) |  |

protected

unsigned short SLNet::FileListTransfer::SetupReceive | ( | FileListTransferCBInterface * | handler,
|  | bool | deleteHandler,
|  | SystemAddress | allowedSender
| ) |  |

Allows one corresponding Send() call from another system to arrive.

Parameters

  [in] | handler | The class to call on each file
  [in] | deleteHandler | True to delete the handler when it is no longer needed. False to not do so.
  [in] | allowedSender | Which system to allow files from.

Returns
  A set ID value, which should be passed as the setID value to the Send() call on the other system. This value will be returned in the callback and is unique per file set. Returns 65535 on failure (not connected to sender)

void SLNet::FileListTransfer::StartIncrementalReadThreads | ( | int | numThreads,
|  | int | threadPriority = `-99999`
| ) |  |

Optionally start worker threads when using _incrementalReadInterface for the Send() operation.

Parameters

  [in] | numThreads | how many worker threads to start
  [in] | threadPriority | Passed to the thread creation routine. Use THREAD_PRIORITY_NORMAL for Windows. For Linux based systems, you MUST pass something reasonable based on the thread priorities for your application.

virtual void SLNet::FileListTransfer::Update | ( | void |  | ) |

virtual

Update is called every time a packet is checked for .

Reimplemented from SLNet::PluginInterface2.

#### Friends And Related Function Documentation

int SendIRIToAddressCB | ( | FileListTransfer::ThreadData | threadData,
|  | bool * | returnOutput,
|  | void * | perThreadData
| ) |  |

friend

#### Member Data Documentation

DataStructures::List<FileListProgress*> SLNet::FileListTransfer::fileListProgressCallbacks

protected

Definition at line 143 of file FileListTransfer.h.

DataStructures::Map<unsigned short, FileListReceiver*> SLNet::FileListTransfer::fileListReceivers

protected

Definition at line 141 of file FileListTransfer.h.

DataStructures::List< FileToPushRecipient* > SLNet::FileListTransfer::fileToPushRecipientList

protected

Definition at line 170 of file FileListTransfer.h.

SimpleMutex SLNet::FileListTransfer::fileToPushRecipientListMutex

protected

Definition at line 171 of file FileListTransfer.h.

unsigned short SLNet::FileListTransfer::setId

protected

Definition at line 142 of file FileListTransfer.h.

ThreadPool<ThreadData, int> SLNet::FileListTransfer::threadPool

protected

Definition at line 181 of file FileListTransfer.h.

struct SLNet::FileListTransfer::FileToPush

Definition at line 145 of file FileListTransfer.h.

Class Members
unsigned int | chunkSize |
unsigned int | currentOffset |
FileListNode | fileListNode |
IncrementalReadInterface * | incrementalReadInterface |
char | orderingChannel |
PacketPriority | packetPriority |
unsigned int | setIndex |

struct SLNet::FileListTransfer::FileToPushRecipient

Definition at line 156 of file FileListTransfer.h.

### Public Member Functions

void | DeleteThis (void)
void | AddRef (void)
void | Deref (void)

### Public Attributes

unsigned int | refCount
SimpleMutex | refCountMutex
SystemAddress | systemAddress
unsigned short | setId
DataStructures::Queue < FileToPush * > | filesToPush

#### Member Function Documentation

void SLNet::FileListTransfer::FileToPushRecipient::AddRef | ( | void |  | ) |

void SLNet::FileListTransfer::FileToPushRecipient::DeleteThis | ( | void |  | ) |

void SLNet::FileListTransfer::FileToPushRecipient::Deref | ( | void |  | ) |

#### Member Data Documentation

DataStructures::Queue<FileToPush*> SLNet::FileListTransfer::FileToPushRecipient::filesToPush

Definition at line 168 of file FileListTransfer.h.

unsigned int SLNet::FileListTransfer::FileToPushRecipient::refCount

Definition at line 158 of file FileListTransfer.h.

SimpleMutex SLNet::FileListTransfer::FileToPushRecipient::refCountMutex

Definition at line 159 of file FileListTransfer.h.

unsigned short SLNet::FileListTransfer::FileToPushRecipient::setId

Definition at line 165 of file FileListTransfer.h.

SystemAddress SLNet::FileListTransfer::FileToPushRecipient::systemAddress

Definition at line 164 of file FileListTransfer.h.

struct SLNet::FileListTransfer::ThreadData

Definition at line 174 of file FileListTransfer.h.

Class Members
FileListTransfer * | fileListTransfer |
unsigned short | setId |
SystemAddress | systemAddress |