![]() |
VR-Link API Documentation for DIS
|
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. | |
| virtual | ~DtFileTransporter () |
| Destructor. | |
| virtual void | tick () |
| Do periodic processing. | |
| virtual unsigned int | port () const |
| Get our listening port. | |
| virtual void | addFileTransferedCallback (DtFileTransferedCallbackFn fn, void *data) |
| Add/Remove callbacks to be invoked when a new file has been transfered to us. | |
| 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. | |
| virtual bool | sendFile (const DtFilename &filename, DtIpv4Addr destAddr) |
| Sends a file to the given destAddr using the myPort. | |
| const DtFilename & | 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. | |
| void | setTargetDirectory (const DtFilename &f) |
Static Public Member Functions | |
| static void | receiveFileCb (DtTcpSocket *sock, void *usr) |
| Invoked when a socket connects to us. | |
Protected Types | |
| typedef std::map < DtFileTransferedCallbackFn, void * > | FileTransferedCallbackMapType |
Protected Member Functions | |
| virtual void | receiveFile (DtTcpSocket *sock) |
| Called when a socket connects to us. | |
| virtual int | nextFileIdentifier () |
| Returns the next unique identifier for the file to be sent. | |
| virtual bool | readFileToBuffer (std::ifstream &inFile, std::vector< char > &fileBuffer, int fileLengthInBytes, int &retBufLen, DtFileTransportFlags &flags) |
| Reads the file into the supplied vector buffer. | |
| virtual void | finishFile (DtFileTransportObject &object) |
| Writes out file and removed transport object from active file list. | |
| virtual DtFileTransportObject & | transportObject (int iFileIdentifier) |
| DtFileTransporter (const DtFileTransporter &) | |
| Copy CTOR Not Implemented. | |
| DtFileTransporter & | operator= (const DtFileTransporter &) |
| Assignment Operator Not Implemented. | |
Protected Attributes | |
| FileTransferedCallbackMapType | myCallbacks |
| int | myPort |
| DtTcpSocketMgr * | mySocketMgr |
| DtFilename | myTargetDirectory |
| DtFileObjectMap | myActiveFiles |
| typedef std::map<int, DtFileTransportObject> DtFileTransporter::DtFileObjectMap |
| typedef void(* DtFileTransporter::DtFileTransferedCallbackFn)(const DtFilename &file, void *usr) |
typedef std::map<DtFileTransferedCallbackFn, void*> DtFileTransporter::FileTransferedCallbackMapType [protected] |
| 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.
| 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 | ) | [protected, virtual] |
Writes out file and removed transport object from active file list.
| virtual int DtFileTransporter::nextFileIdentifier | ( | ) | [protected, virtual] |
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 | ||
| ) | [protected, virtual] |
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 | ) | [protected, virtual] |
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 | ) | [protected, virtual] |
DtFileObjectMap DtFileTransporter::myActiveFiles [protected] |
int DtFileTransporter::myPort [protected] |
DtTcpSocketMgr* DtFileTransporter::mySocketMgr [protected] |
DtFilename DtFileTransporter::myTargetDirectory [protected] |