1 /// \file
2 ///
3 /// This file is part of RakNet Copyright 2003 Jenkins Software LLC
4 ///
5 /// Raknet is available under the terms of the GPLv3 license, see /usr/local/share/licenses/raknet-3.9.2_10,1/GPLv3.
6 
7 
8 #include "PluginInterface2.h"
9 #include "PacketizedTCP.h"
10 #include "RakPeerInterface.h"
11 #include "BitStream.h"
12 
PluginInterface2()13 PluginInterface2::PluginInterface2()
14 {
15 	rakPeerInterface=0;
16 #if _RAKNET_SUPPORT_PacketizedTCP==1
17 	packetizedTCP=0;
18 #endif
19 }
~PluginInterface2()20 PluginInterface2::~PluginInterface2()
21 {
22 
23 }
SendUnified(const RakNet::BitStream * bitStream,PacketPriority priority,PacketReliability reliability,char orderingChannel,const AddressOrGUID systemIdentifier,bool broadcast)24 void PluginInterface2::SendUnified( const RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast )
25 {
26 	if (rakPeerInterface)
27 		rakPeerInterface->Send(bitStream,priority,reliability,orderingChannel,systemIdentifier,broadcast);
28 #if _RAKNET_SUPPORT_PacketizedTCP==1
29 	else
30 		packetizedTCP->Send((const char*) bitStream->GetData(), bitStream->GetNumberOfBytesUsed(), systemIdentifier.systemAddress, broadcast);
31 #endif
32 }
AllocatePacketUnified(unsigned dataSize)33 Packet *PluginInterface2::AllocatePacketUnified(unsigned dataSize)
34 {
35 	if (rakPeerInterface)
36 		return rakPeerInterface->AllocatePacket(dataSize);
37 #if _RAKNET_SUPPORT_PacketizedTCP==1
38 	else
39 		return packetizedTCP->AllocatePacket(dataSize);
40 #else
41 	return 0;
42 #endif
43 
44 }
PushBackPacketUnified(Packet * packet,bool pushAtHead)45 void PluginInterface2::PushBackPacketUnified(Packet *packet, bool pushAtHead)
46 {
47 	if (rakPeerInterface)
48 		rakPeerInterface->PushBackPacket(packet,pushAtHead);
49 #if _RAKNET_SUPPORT_PacketizedTCP==1
50 	else
51 		packetizedTCP->PushBackPacket(packet,pushAtHead);
52 #endif
53 }
DeallocPacketUnified(Packet * packet)54 void PluginInterface2::DeallocPacketUnified(Packet *packet)
55 {
56 	if (rakPeerInterface)
57 		rakPeerInterface->DeallocatePacket(packet);
58 #if _RAKNET_SUPPORT_PacketizedTCP==1
59 	else
60 		packetizedTCP->DeallocatePacket(packet);
61 #endif
62 }
SendListUnified(const char ** data,const int * lengths,const int numParameters,PacketPriority priority,PacketReliability reliability,char orderingChannel,const AddressOrGUID systemIdentifier,bool broadcast)63 bool PluginInterface2::SendListUnified( const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast )
64 {
65 	if (rakPeerInterface)
66 	{
67 		return rakPeerInterface->SendList(data,lengths,numParameters,priority,reliability,orderingChannel,systemIdentifier,broadcast)!=0;
68 	}
69 #if _RAKNET_SUPPORT_PacketizedTCP==1
70 	else
71 	{
72 		return packetizedTCP->SendList(data,lengths,numParameters,systemIdentifier.systemAddress,broadcast );
73 	}
74 #else
75 	return false;
76 #endif
77 }
SetRakPeerInterface(RakPeerInterface * ptr)78 void PluginInterface2::SetRakPeerInterface( RakPeerInterface *ptr )
79 {
80 	rakPeerInterface=ptr;
81 }
82 #if _RAKNET_SUPPORT_PacketizedTCP==1
SetPacketizedTCP(PacketizedTCP * ptr)83 void PluginInterface2::SetPacketizedTCP( PacketizedTCP *ptr )
84 {
85 	packetizedTCP=ptr;
86 }
87 #endif
88