Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "PluginInterface2.h"
00009 #include "PacketizedTCP.h"
00010 #include "RakPeerInterface.h"
00011 #include "BitStream.h"
00012
00013 PluginInterface2::PluginInterface2()
00014 {
00015 rakPeerInterface=0;
00016 #if _RAKNET_SUPPORT_PacketizedTCP==1
00017 packetizedTCP=0;
00018 #endif
00019 }
00020 PluginInterface2::~PluginInterface2()
00021 {
00022
00023 }
00024 void PluginInterface2::SendUnified( const RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast )
00025 {
00026 if (rakPeerInterface)
00027 rakPeerInterface->Send(bitStream,priority,reliability,orderingChannel,systemIdentifier,broadcast);
00028 #if _RAKNET_SUPPORT_PacketizedTCP==1
00029 else
00030 packetizedTCP->Send((const char*) bitStream->GetData(), bitStream->GetNumberOfBytesUsed(), systemIdentifier.systemAddress, broadcast);
00031 #endif
00032 }
00033 Packet *PluginInterface2::AllocatePacketUnified(unsigned dataSize)
00034 {
00035 if (rakPeerInterface)
00036 return rakPeerInterface->AllocatePacket(dataSize);
00037 #if _RAKNET_SUPPORT_PacketizedTCP==1
00038 else
00039 return packetizedTCP->AllocatePacket(dataSize);
00040 #else
00041 return 0;
00042 #endif
00043
00044 }
00045 void PluginInterface2::PushBackPacketUnified(Packet *packet, bool pushAtHead)
00046 {
00047 if (rakPeerInterface)
00048 rakPeerInterface->PushBackPacket(packet,pushAtHead);
00049 #if _RAKNET_SUPPORT_PacketizedTCP==1
00050 else
00051 packetizedTCP->PushBackPacket(packet,pushAtHead);
00052 #endif
00053 }
00054 void PluginInterface2::DeallocPacketUnified(Packet *packet)
00055 {
00056 if (rakPeerInterface)
00057 rakPeerInterface->DeallocatePacket(packet);
00058 #if _RAKNET_SUPPORT_PacketizedTCP==1
00059 else
00060 packetizedTCP->DeallocatePacket(packet);
00061 #endif
00062 }
00063 bool PluginInterface2::SendListUnified( const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast )
00064 {
00065 if (rakPeerInterface)
00066 {
00067 return rakPeerInterface->SendList(data,lengths,numParameters,priority,reliability,orderingChannel,systemIdentifier,broadcast)!=0;
00068 }
00069 #if _RAKNET_SUPPORT_PacketizedTCP==1
00070 else
00071 {
00072 return packetizedTCP->SendList(data,lengths,numParameters,systemIdentifier.systemAddress,broadcast );
00073 }
00074 #else
00075 return false;
00076 #endif
00077 }
00078 void PluginInterface2::SetRakPeerInterface( RakPeerInterface *ptr )
00079 {
00080 rakPeerInterface=ptr;
00081 }
00082 #if _RAKNET_SUPPORT_PacketizedTCP==1
00083 void PluginInterface2::SetPacketizedTCP( PacketizedTCP *ptr )
00084 {
00085 packetizedTCP=ptr;
00086 }
00087 #endif