VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetFileTransport.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
10 #ifndef VXWORKS
11 
14 #include "vlFilename.h"
15 #include "vlString.h"
16 #include "vlUtil.h"
17 #include "vlInetAddr.h"
18 
19 #include <fstream>
20 #include <map>
21 #include <vector>
22 
23 #ifdef DtUSE_UTILITIES_NAMESPACE
24 namespace DtUSE_UTILITIES_NAMESPACE
25 {
26 #endif
27 
28 
29 class DtInetSocket;
30 class DtInetTcpSocket;
31 class DtInetSocketMgr;
32 
34 {
35 public:
38 
40 
44  unsigned long myBufferLength;
45  unsigned long myBytesReceived;
46  std::vector<char> myBuffer;
47  int myFlags;
48 };
49 
51 {
52 public:
53 
54  typedef void (*DtInetFileTransferedCallbackFn)
55  (const DtFilename& file, void* usr);
56 
57  typedef std::map<int, DtInetFileTransportObject> DtFileObjectMap;
58 
60  {
61  DtFileNormal = 0,
62  DtFileCompressed = 1,
63  DtFileEncrypted = 2
64  };
65 
66 public:
67 
76  int port = 3000,
77  bool findFirstAvailable = false,
78  int portRangeToTry = 10,
79  const DtFilename &tagetDirectory = ".",
80  int *status = 0,
81  bool useIpv6 = false);
82 
84  virtual ~DtInetFileTransporter();
85 
87  virtual void tick();
88 
91  virtual unsigned int port() const;
92 
95  virtual void addFileTransferedCallback(
96  DtInetFileTransferedCallbackFn fn, void* data);
97  virtual void removeFileTransferedCallback(
98  DtInetFileTransferedCallbackFn fn, void* data);
99 
101  virtual bool sendFile(
102  const DtFilename& filename, const DtInetAddr& destAddr, int port);
103 
105  virtual bool sendFile(
106  const DtFilename& filename, const DtInetAddr& destAddr);
107 
112  const DtFilename& targetDirectory() const;
113  void setTargetDirectory(const DtFilename& f);
114 
115 public:
116 
118 // static void receiveFileCb(DtTcpSocket* sock, void* usr);
119  static bool receiveFileCb(DtInetSocket* sock, void* usr);
120 
121 protected:
122 
127 // virtual void receiveFile(DtTcpSocket* sock);
128  virtual void receiveFile(DtInetTcpSocket* sock);
129 
133  virtual int nextFileIdentifier();
134 
141  virtual bool readFileToBuffer(std::ifstream& inFile,
142  std::vector<char>& fileBuffer, int fileLengthInBytes, int& retBufLen,
143  DtInetFileTransportFlags& flags);
144 
146  virtual void finishFile(DtInetFileTransportObject& object);
147 
148  virtual DtInetFileTransportObject& transportObject(int iFileIdentifier);
149 
150 protected:
151 
154 
156  DtInetFileTransporter& operator=(const DtInetFileTransporter&);
157 
158 protected:
159 
160  typedef std::map<DtInetFileTransferedCallbackFn, void*> FileTransferedCallbackMapType;
161 
162 protected:
163 
165  int myPort;
168 
170 };
171 
172 #ifdef DtUSE_UTILITIES_NAMESPACE
173 }
174 #endif
175 
176 #endif
177 

Document ID: Generated on Mon Jun 22 21:18:40 EDT 2020 from SVN revision 213785
Copyright © 2005-2018 MAK Technologies. All Rights Reserved (www.mak.com)