Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
RakNet::FileListTransfer Class Reference

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

#include <FileListTransfer.h>

Inheritance diagram for RakNet::FileListTransfer:

List of all members.

Classes

struct  FileToPush
struct  FileToPushRecipient
struct  ThreadData

Public Member Functions

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

Static Public Member Functions

static void DestroyInstance (FileListTransfer *i)
static FileListTransferGetInstance (void)

Protected Member Functions

void Clear (void)
bool DecodeFile (Packet *packet, bool fullFile)
bool DecodeSetHeader (Packet *packet)
void OnReferencePush (Packet *packet, bool fullFile)
void OnReferencePushAck (Packet *packet)
void RemoveFromList (FileToPushRecipient *ftpr)
void SendIRIToAddress (SystemAddress systemAddress)

Protected Attributes

DataStructures::List
< FileListProgress * > 
fileListProgressCallbacks
DataStructures::Map< unsigned
short, FileListReceiver * > 
fileListReceivers
DataStructures::List
< FileToPushRecipient * > 
fileToPushRecipientList
SimpleMutex fileToPushRecipientListMutex
unsigned short setId
ThreadPool< ThreadData, int > threadPool

Friends

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

Detailed Description

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 49 of file FileListTransfer.h.


Constructor & Destructor Documentation

RakNet::FileListTransfer::FileListTransfer ( )
virtual RakNet::FileListTransfer::~FileListTransfer ( ) [virtual]

Member Function Documentation

void RakNet::FileListTransfer::AddCallback ( FileListProgress cb)
Parameters:
[in]cbA 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 RakNet::FileListTransfer::CancelReceive ( unsigned short  setId)
void RakNet::FileListTransfer::Clear ( void  ) [protected]
void RakNet::FileListTransfer::ClearCallbacks ( void  )
bool RakNet::FileListTransfer::DecodeFile ( Packet packet,
bool  fullFile 
) [protected]
bool RakNet::FileListTransfer::DecodeSetHeader ( Packet packet) [protected]
static void RakNet::FileListTransfer::DestroyInstance ( FileListTransfer i) [static]
void RakNet::FileListTransfer::GetCallbacks ( DataStructures::List< FileListProgress * > &  callbacks)

Returns all callbacks added with AddCallback()

Parameters:
[out]callbacksThe list is set to the list of callbacks
static FileListTransfer* RakNet::FileListTransfer::GetInstance ( void  ) [static]
unsigned int RakNet::FileListTransfer::GetPendingFilesToAddress ( SystemAddress  recipient)
bool RakNet::FileListTransfer::IsHandlerActive ( unsigned short  setId)
virtual void RakNet::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]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual void RakNet::FileListTransfer::OnRakPeerShutdown ( void  ) [virtual]

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::FileListTransfer::OnReceive ( Packet packet) [virtual]

OnReceive is called for every packet.

Parameters:
[in]packetthe 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 RakNet::PluginInterface2.

void RakNet::FileListTransfer::OnReferencePush ( Packet packet,
bool  fullFile 
) [protected]
void RakNet::FileListTransfer::OnReferencePushAck ( Packet packet) [protected]
void RakNet::FileListTransfer::RemoveCallback ( FileListProgress cb)
Parameters:
[in]cbA pointer to an externally defined instance of FileListProgress that was previously added with AddCallback()
void RakNet::FileListTransfer::RemoveFromList ( FileToPushRecipient ftpr) [protected]
void RakNet::FileListTransfer::RemoveReceiver ( SystemAddress  systemAddress)
void RakNet::FileListTransfer::Send ( FileList fileList,
RakNet::RakPeerInterface rakPeer,
SystemAddress  recipient,
unsigned short  setID,
PacketPriority  priority,
char  orderingChannel,
IncrementalReadInterface _incrementalReadInterface = 0,
unsigned int  _chunkSize = 262144 *4 *16 
)
Parameters:
[in]fileListA list of files. The data contained in FileList::data will be sent incrementally and compressed among all files in the set
[in]rakPeerThe instance of RakNet to use to send the message. Pass 0 to use the instance the plugin is attached to
[in]recipientThe address of the system to send to
[in]setIDThe return value of SetupReceive() which was previously called on recipient
[in]priorityPassed to RakPeerInterface::Send()
[in]orderingChannelPassed to RakPeerInterface::Send()
[in]_incrementalReadInterfaceIf a file in fileList has no data, _incrementalReadInterface will be used to read the file in chunks of size chunkSize
[in]_chunkSizeHow large of a block of a file to send at once
void RakNet::FileListTransfer::SendIRIToAddress ( SystemAddress  systemAddress) [protected]
unsigned short RakNet::FileListTransfer::SetupReceive ( FileListTransferCBInterface handler,
bool  deleteHandler,
SystemAddress  allowedSender 
)
Parameters:
[in]handlerThe class to call on each file
[in]deleteHandlerTrue to delete the handler when it is no longer needed. False to not do so.
[in]allowedSenderWhich 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 RakNet::FileListTransfer::StartIncrementalReadThreads ( int  numThreads,
int  threadPriority = -99999 
)
Parameters:
[in]numThreadshow many worker threads to start
[in]threadPriorityPassed 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 RakNet::FileListTransfer::Update ( void  ) [virtual]

Reimplemented from RakNet::PluginInterface2.


Friends And Related Function Documentation

int SendIRIToAddressCB ( FileListTransfer::ThreadData  threadData,
bool returnOutput,
void *  perThreadData 
) [friend]

Member Data Documentation

Definition at line 130 of file FileListTransfer.h.

DataStructures::Map<unsigned short, FileListReceiver*> RakNet::FileListTransfer::fileListReceivers [protected]

Definition at line 128 of file FileListTransfer.h.

Definition at line 154 of file FileListTransfer.h.

Definition at line 155 of file FileListTransfer.h.

unsigned short RakNet::FileListTransfer::setId [protected]

Definition at line 129 of file FileListTransfer.h.

Definition at line 164 of file FileListTransfer.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net