VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
DtFileTransporter Class Reference
+ Collaboration diagram for DtFileTransporter:

Public Types

enum  DtFileTransportFlags { DtFileNormal = 0, DtFileCompressed = 1, DtFileEncrypted = 2 }
 
typedef void(* DtFileTransferedCallbackFn )(const DtFilename &file, void *usr)
 
typedef std::map< int,
DtFileTransportObject
DtFileObjectMap
 

Public Member Functions

 DtFileTransporter (int port=DtDEFAULT_PORT, bool findFirstAvailable=false, int portRangeToTry=10, const DtFilename &tagetDirectory=".", int *status=0)
 Constructor. More...
 
virtual ~DtFileTransporter ()
 Destructor. More...
 
virtual void tick ()
 Do periodic processing. More...
 
virtual unsigned int port () const
 Get our listening port. More...
 
virtual void addFileTransferedCallback (DtFileTransferedCallbackFn fn, void *data)
 Add/Remove callbacks to be invoked when a new file has been transfered to us. More...
 
virtual void removeFileTransferedCallback (DtFileTransferedCallbackFn fn, void *data)
 
virtual bool sendFile (const DtFilename &filename, DtIpv4Addr destAddr, int port)
 Sends a file to the given destAddr and port. More...
 
virtual bool sendFile (const DtFilename &filename, DtIpv4Addr destAddr)
 Sends a file to the given destAddr using the myPort. More...
 
const DtFilenametargetDirectory () const
 Set/Get the directory where incoming files will be stored When setting a new directory, the given directory will be created if it does not exist already. More...
 
void setTargetDirectory (const DtFilename &f)
 

Static Public Member Functions

static void receiveFileCb (DtTcpSocket *sock, void *usr)
 Invoked when a socket connects to us. More...
 

Protected Types

typedef std::map
< DtFileTransferedCallbackFn,
void * > 
FileTransferedCallbackMapType
 

Protected Member Functions

virtual void receiveFile (DtTcpSocket *sock)
 Called when a socket connects to us. More...
 
virtual int nextFileIdentifier ()
 Returns the next unique identifier for the file to be sent. More...
 
virtual bool readFileToBuffer (std::ifstream &inFile, std::vector< char > &fileBuffer, int fileLengthInBytes, int &retBufLen, DtFileTransportFlags &flags)
 Reads the file into the supplied vector buffer. More...
 
virtual void finishFile (DtFileTransportObject &object)
 Writes out file and removed transport object from active file list. More...
 
virtual DtFileTransportObjecttransportObject (int iFileIdentifier)
 
 DtFileTransporter (const DtFileTransporter &)
 Copy CTOR Not Implemented. More...
 
DtFileTransporteroperator= (const DtFileTransporter &)
 Assignment Operator Not Implemented. More...
 

Protected Attributes

FileTransferedCallbackMapType myCallbacks
 
int myPort
 
DtTcpSocketMgrmySocketMgr
 
DtFilename myTargetDirectory
 
DtFileObjectMap myActiveFiles
 

Member Typedef Documentation

typedef void(* DtFileTransporter::DtFileTransferedCallbackFn)(const DtFilename &file, void *usr)

Member Enumeration Documentation

Enumerator
DtFileNormal 
DtFileCompressed 
DtFileEncrypted 

Constructor & Destructor Documentation

DtFileTransporter::DtFileTransporter ( int  port = DtDEFAULT_PORT,
bool  findFirstAvailable = false,
int  portRangeToTry = 10,
const DtFilename tagetDirectory = ".",
int status = 0 
)

Constructor.

Accepts incoming data from the given port. Set findFirstAvailable to true when you want the listener to try to find the next free port if the given port is already in use. If the suggested port is not free, and findFirstAvailable is set to true, DtFileTransporter will try the next portRangeToTry ports. On success status returns the port which was opened for reading. On failure status returns a negative value.

virtual DtFileTransporter::~DtFileTransporter ( )
virtual

Destructor.

DtFileTransporter::DtFileTransporter ( const DtFileTransporter )
protected

Copy CTOR Not Implemented.

Member Function Documentation

virtual void DtFileTransporter::addFileTransferedCallback ( DtFileTransferedCallbackFn  fn,
void *  data 
)
virtual

Add/Remove callbacks to be invoked when a new file has been transfered to us.

virtual void DtFileTransporter::finishFile ( DtFileTransportObject object)
protectedvirtual

Writes out file and removed transport object from active file list.

virtual int DtFileTransporter::nextFileIdentifier ( )
protectedvirtual

Returns the next unique identifier for the file to be sent.

Used when reading in files from the network to make sure that file packets are associated with the right files

DtFileTransporter& DtFileTransporter::operator= ( const DtFileTransporter )
protected

Assignment Operator Not Implemented.

virtual unsigned int DtFileTransporter::port ( ) const
virtual

Get our listening port.

(Ie. the port number on which we are receiving connections)

virtual bool DtFileTransporter::readFileToBuffer ( std::ifstream &  inFile,
std::vector< char > &  fileBuffer,
int  fileLengthInBytes,
int retBufLen,
DtFileTransportFlags flags 
)
protectedvirtual

Reads the file into the supplied vector buffer.

The retBufLen pointer will contain the actual size of the buffer. Set flags to any changes that are made to the file read in.

Set retBufLen to the actual size of the returned buffer. By default it will be set to fileLengthInBytes

virtual void DtFileTransporter::receiveFile ( DtTcpSocket sock)
protectedvirtual

Called when a socket connects to us.

This should never be called directly by users. Instead, users should register a callback to know when a file has been received.

static void DtFileTransporter::receiveFileCb ( DtTcpSocket sock,
void *  usr 
)
static

Invoked when a socket connects to us.

virtual void DtFileTransporter::removeFileTransferedCallback ( DtFileTransferedCallbackFn  fn,
void *  data 
)
virtual
virtual bool DtFileTransporter::sendFile ( const DtFilename filename,
DtIpv4Addr  destAddr,
int  port 
)
virtual

Sends a file to the given destAddr and port.

virtual bool DtFileTransporter::sendFile ( const DtFilename filename,
DtIpv4Addr  destAddr 
)
virtual

Sends a file to the given destAddr using the myPort.

void DtFileTransporter::setTargetDirectory ( const DtFilename f)
const DtFilename& DtFileTransporter::targetDirectory ( ) const

Set/Get the directory where incoming files will be stored When setting a new directory, the given directory will be created if it does not exist already.

The default is the current directory.

virtual void DtFileTransporter::tick ( )
virtual

Do periodic processing.

virtual DtFileTransportObject& DtFileTransporter::transportObject ( int  iFileIdentifier)
protectedvirtual

Member Data Documentation

DtFileObjectMap DtFileTransporter::myActiveFiles
protected
FileTransferedCallbackMapType DtFileTransporter::myCallbacks
protected
int DtFileTransporter::myPort
protected
DtTcpSocketMgr* DtFileTransporter::mySocketMgr
protected
DtFilename DtFileTransporter::myTargetDirectory
protected

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

Document ID: Generated on Wed Mar 27 02:04:30 EDT 2024 from SVN revision 264570
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)