![]() |
VR-Link API Documentation for HLA 1.3
|
Collaboration diagram for DtInetFileTransporter:Public Types | |
| enum | DtInetFileTransportFlags { DtFileNormal = 0, DtFileCompressed = 1, DtFileEncrypted = 2 } |
| typedef void(* | DtInetFileTransferedCallbackFn )(const DtFilename &file, void *usr) |
| typedef std::map< int, DtInetFileTransportObject > | DtFileObjectMap |
Public Member Functions | |
| DtInetFileTransporter (int port=3000, bool findFirstAvailable=false, int portRangeToTry=10, const DtFilename &tagetDirectory=".", int *status=0, bool useIpv6=false) | |
| Constructor. | |
| virtual | ~DtInetFileTransporter () |
| Destructor. | |
| virtual void | tick () |
| Do periodic processing. | |
| virtual unsigned int | port () const |
| Get our listening port. | |
| virtual void | addFileTransferedCallback (DtInetFileTransferedCallbackFn fn, void *data) |
| Add/Remove callbacks to be invoked when a new file has been transfered to us. | |
| virtual void | removeFileTransferedCallback (DtInetFileTransferedCallbackFn fn, void *data) |
| virtual bool | sendFile (const DtFilename &filename, const DtInetAddr &destAddr, int port) |
| Sends a file to the given destAddr and port. | |
| virtual bool | sendFile (const DtFilename &filename, const DtInetAddr &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 bool | receiveFileCb (DtInetSocket *sock, void *usr) |
| Invoked when a socket connects to us. | |
Protected Types | |
| typedef std::map < DtInetFileTransferedCallbackFn, void * > | FileTransferedCallbackMapType |
Protected Member Functions | |
| virtual void | receiveFile (DtInetTcpSocket *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, DtInetFileTransportFlags &flags) |
| Reads the file into the supplied vector buffer. | |
| virtual void | finishFile (DtInetFileTransportObject &object) |
| Writes out file and removed transport object from active file list. | |
| virtual DtInetFileTransportObject & | transportObject (int iFileIdentifier) |
| DtInetFileTransporter (const DtInetFileTransporter &) | |
| Copy CTOR Not Implemented. | |
| DtInetFileTransporter & | operator= (const DtInetFileTransporter &) |
| Assignment Operator Not Implemented. | |
Protected Attributes | |
| FileTransferedCallbackMapType | myCallbacks |
| int | myPort |
| DtInetSocketMgr * | mySocketMgr |
| DtFilename | myTargetDirectory |
| DtFileObjectMap | myActiveFiles |
| typedef std::map<int, DtInetFileTransportObject> DtInetFileTransporter::DtFileObjectMap |
| typedef void(* DtInetFileTransporter::DtInetFileTransferedCallbackFn)(const DtFilename &file, void *usr) |
typedef std::map<DtInetFileTransferedCallbackFn, void*> DtInetFileTransporter::FileTransferedCallbackMapType [protected] |
| DtInetFileTransporter::DtInetFileTransporter | ( | int | port = 3000, |
| bool | findFirstAvailable = false, |
||
| int | portRangeToTry = 10, |
||
| const DtFilename & | tagetDirectory = ".", |
||
| int * | status = 0, |
||
| bool | useIpv6 = false |
||
| ) |
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, DtInetFileTransporter 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 DtInetFileTransporter::~DtInetFileTransporter | ( | ) | [virtual] |
Destructor.
| DtInetFileTransporter::DtInetFileTransporter | ( | const DtInetFileTransporter & | ) | [protected] |
Copy CTOR Not Implemented.
| virtual void DtInetFileTransporter::addFileTransferedCallback | ( | DtInetFileTransferedCallbackFn | fn, |
| void * | data | ||
| ) | [virtual] |
Add/Remove callbacks to be invoked when a new file has been transfered to us.
| virtual void DtInetFileTransporter::finishFile | ( | DtInetFileTransportObject & | object | ) | [protected, virtual] |
Writes out file and removed transport object from active file list.
| virtual int DtInetFileTransporter::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
| DtInetFileTransporter& DtInetFileTransporter::operator= | ( | const DtInetFileTransporter & | ) | [protected] |
Assignment Operator Not Implemented.
| virtual unsigned int DtInetFileTransporter::port | ( | ) | const [virtual] |
Get our listening port.
(Ie. the port number on which we are receiving connections)
| virtual bool DtInetFileTransporter::readFileToBuffer | ( | std::ifstream & | inFile, |
| std::vector< char > & | fileBuffer, | ||
| int | fileLengthInBytes, | ||
| int & | retBufLen, | ||
| DtInetFileTransportFlags & | 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 DtInetFileTransporter::receiveFile | ( | DtInetTcpSocket * | 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 bool DtInetFileTransporter::receiveFileCb | ( | DtInetSocket * | sock, |
| void * | usr | ||
| ) | [static] |
Invoked when a socket connects to us.
| virtual void DtInetFileTransporter::removeFileTransferedCallback | ( | DtInetFileTransferedCallbackFn | fn, |
| void * | data | ||
| ) | [virtual] |
| virtual bool DtInetFileTransporter::sendFile | ( | const DtFilename & | filename, |
| const DtInetAddr & | destAddr, | ||
| int | port | ||
| ) | [virtual] |
Sends a file to the given destAddr and port.
| virtual bool DtInetFileTransporter::sendFile | ( | const DtFilename & | filename, |
| const DtInetAddr & | destAddr | ||
| ) | [virtual] |
Sends a file to the given destAddr using the myPort.
| void DtInetFileTransporter::setTargetDirectory | ( | const DtFilename & | f | ) |
| const DtFilename& DtInetFileTransporter::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 DtInetFileTransporter::tick | ( | ) | [virtual] |
Do periodic processing.
| virtual DtInetFileTransportObject& DtInetFileTransporter::transportObject | ( | int | iFileIdentifier | ) | [protected, virtual] |
DtFileObjectMap DtInetFileTransporter::myActiveFiles [protected] |
int DtInetFileTransporter::myPort [protected] |
DtInetSocketMgr* DtInetFileTransporter::mySocketMgr [protected] |
DtFilename DtInetFileTransporter::myTargetDirectory [protected] |