![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 00002 00003 00004 00005 00006 00007 00008 #include "NativeFeatureIncludes.h" 00009 #if _RAKNET_SUPPORT_PacketizedTCP==1 && _RAKNET_SUPPORT_TCPInterface==1 00010 00011 #ifndef __PACKETIZED_TCP 00012 #define __PACKETIZED_TCP 00013 00014 #include "TCPInterface.h" 00015 #include "DS_ByteQueue.h" 00016 #include "PluginInterface2.h" 00017 #include "DS_Map.h" 00018 00019 namespace RakNet 00020 { 00021 00022 class RAK_DLL_EXPORT PacketizedTCP : public TCPInterface 00023 { 00024 public: 00025 // GetInstance() and DestroyInstance(instance*) 00026 STATIC_FACTORY_DECLARATIONS(PacketizedTCP) 00027 00028 PacketizedTCP(); 00029 virtual ~PacketizedTCP(); 00030 00037 bool Start(unsigned short port, unsigned short maxIncomingConnections, int threadPriority=-99999, unsigned short socketFamily=AF_INET); 00038 00040 void Stop(void); 00041 00043 void Send( const char *data, unsigned length, const SystemAddress &systemAddress, bool broadcast ); 00044 00045 // Sends a concatenated list of byte streams 00046 bool SendList( const char **data, const int *lengths, const int numParameters, const SystemAddress &systemAddress, bool broadcast ); 00047 00049 Packet* Receive( void ); 00050 00052 void CloseConnection( SystemAddress systemAddress ); 00053 00056 SystemAddress HasCompletedConnectionAttempt(void); 00057 00060 SystemAddress HasFailedConnectionAttempt(void); 00061 00063 SystemAddress HasNewIncomingConnection(void); 00064 00066 SystemAddress HasLostConnection(void); 00067 00068 // Only currently tested with FileListTransfer! 00069 void AttachPlugin( PluginInterface2 *plugin ); 00070 void DetachPlugin( PluginInterface2 *plugin ); 00071 00072 protected: 00073 void ClearAllConnections(void); 00074 void RemoveFromConnectionList(const SystemAddress &sa); 00075 void AddToConnectionList(const SystemAddress &sa); 00076 void PushNotificationsToQueues(void); 00077 Packet *ReturnOutgoingPacket(void); 00078 00079 // Plugins 00080 DataStructures::List<PluginInterface2*> messageHandlerList; 00081 // A single TCP recieve may generate multiple split packets. They are stored in the waitingPackets list until Receive is called 00082 DataStructures::Queue<Packet*> waitingPackets; 00083 DataStructures::Map<SystemAddress, DataStructures::ByteQueue *> connections; 00084 00085 // Mirrors single producer / consumer, but processes them in Receive() before returning to user 00086 DataStructures::Queue<SystemAddress> _newIncomingConnections, _lostConnections, _failedConnectionAttempts, _completedConnectionAttempts; 00087 }; 00088 00089 } // namespace RakNet 00090 00091 #endif 00092 00093 #endif // _RAKNET_SUPPORT_*
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.