SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HTTPConnection2.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20 #include "NativeFeatureIncludes.h"
21 #if _RAKNET_SUPPORT_HTTPConnection2==1 && _RAKNET_SUPPORT_TCPInterface==1
22
23 #ifndef __HTTP_CONNECTION_2
24 #define __HTTP_CONNECTION_2
25
26 #include "Export.h"
27 #include "string.h"
28 #include "memoryoverride.h"
29 #include "types.h"
30 #include "DS_List.h"
31 #include "DS_Queue.h"
32 #include "PluginInterface2.h"
33 #include "SimpleMutex.h"
34
35 namespace SLNet
36 {
38 class TCPInterface;
39 struct SystemAddress;
40
44 class RAK_DLL_EXPORT HTTPConnection2 : public PluginInterface2
45 {
46 public:
47 // GetInstance() and DestroyInstance(instance*)
48 STATIC_FACTORY_DECLARATIONS(HTTPConnection2)
49
50 HTTPConnection2();
51 virtual ~HTTPConnection2();
52
63 bool TransmitRequest(const char* stringToTransmit, const char* host, unsigned short port=80, bool useSSL=false, int ipVersion=4, SystemAddress useAddress=UNASSIGNED_SYSTEM_ADDRESS, void *userData=0);
64
76 bool GetResponse( RakString &stringTransmitted, RakString &hostTransmitted, RakString &responseReceived, SystemAddress &hostReceived, ptrdiff_t &contentOffset, void **userData );
77 bool GetResponse( RakString &stringTransmitted, RakString &hostTransmitted, RakString &responseReceived, SystemAddress &hostReceived, ptrdiff_t &contentOffset );
78
80 bool IsBusy(void) const;
81
83 bool HasResponse(void) const;
84
85 struct Request
86 {
87 RakString stringToTransmit;
88 RakString stringReceived;
89 RakString host;
90 SystemAddress hostEstimatedAddress;
91 SystemAddress hostCompletedAddress;
92 unsigned short port;
93 bool useSSL;
94 ptrdiff_t contentOffset;
95 int contentLength;
96 int ipVersion;
97 void *userData;
98 bool chunked;
99 size_t thisChunkSize;
100 size_t bytesReadForThisChunk;
101 };
102
104 virtual PluginReceiveResult OnReceive(Packet *packet);
105 virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
106 virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
107 virtual void OnFailedConnectionAttempt(Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason);
108
109 protected:
110
111 bool IsConnected(SystemAddress sa);
112 void SendRequest(Request *request);
113 void RemovePendingRequest(SystemAddress sa);
114 void SendNextPendingRequest(void);
115 void SendPendingRequestToConnectedSystem(SystemAddress sa);
116
117 DataStructures::Queue<Request*> pendingRequests;
118 DataStructures::List<Request*> sentRequests;
119 DataStructures::List<Request*> completedRequests;
120
121 SimpleMutex pendingRequestsMutex, sentRequestsMutex, completedRequestsMutex;
122
123 };
124
125 } // namespace SLNet
126
127 #endif
128
129 #endif // _RAKNET_SUPPORT_*