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
PacketizedTCP.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) 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
21 #include "NativeFeatureIncludes.h"
22 #if _RAKNET_SUPPORT_PacketizedTCP==1 && _RAKNET_SUPPORT_TCPInterface==1
23
24 #ifndef __PACKETIZED_TCP
25 #define __PACKETIZED_TCP
26
27 #include "TCPInterface.h"
28 #include "DS_ByteQueue.h"
29 #include "DS_Map.h"
30
31 namespace SLNet
32 {
33
34 class RAK_DLL_EXPORT PacketizedTCP : public TCPInterface
35 {
36 public:
37 // GetInstance() and DestroyInstance(instance*)
38 STATIC_FACTORY_DECLARATIONS(PacketizedTCP)
39
40 PacketizedTCP();
41 virtual ~PacketizedTCP();
42
44 void Stop(void);
45
47 void Send( const char *data, unsigned length, const SystemAddress &systemAddress, bool broadcast );
48
49 // Sends a concatenated list of byte streams
50 bool SendList( const char **data, const unsigned int *lengths, const int numParameters, const SystemAddress &systemAddress, bool broadcast );
51
53 Packet* Receive( void );
54
56 void CloseConnection( SystemAddress systemAddress );
57
60 SystemAddress HasCompletedConnectionAttempt(void);
61
64 SystemAddress HasFailedConnectionAttempt(void);
65
67 SystemAddress HasNewIncomingConnection(void);
68
70 SystemAddress HasLostConnection(void);
71
72 protected:
73 void ClearAllConnections(void);
74 void RemoveFromConnectionList(const SystemAddress &sa);
75 void AddToConnectionList(const SystemAddress &sa);
76 void PushNotificationsToQueues(void);
77 Packet *ReturnOutgoingPacket(void);
78
79 // A single TCP recieve may generate multiple split packets. They are stored in the waitingPackets list until Receive is called
80 DataStructures::Queue<Packet*> waitingPackets;
81 DataStructures::Map<SystemAddress, DataStructures::ByteQueue *> connections;
82
83 // Mirrors single producer / consumer, but processes them in Receive() before returning to user
84 DataStructures::Queue<SystemAddress> _newIncomingConnections, _lostConnections, _failedConnectionAttempts, _completedConnectionAttempts;
85 };
86
87 } // namespace SLNet
88
89 #endif
90
91 #endif // _RAKNET_SUPPORT_*