nSendBuffer Class Reference

#include <nNetwork.h>

Collaboration diagram for nSendBuffer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

int Len () const
void AddMessage (nMessage &message, nBandwidthControl *control)
void Send (nSocket const &socket, const nAddress &peer, nBandwidthControl *control)
void Broadcast (nSocket const &socket, int port, nBandwidthControl *control)
void Clear ()

Private Attributes

tArray< unsigned short > sendBuffer_


Detailed Description

Definition at line 175 of file nNetwork.h.


Member Function Documentation

int nSendBuffer::Len (  )  const [inline]

Definition at line 178 of file nNetwork.h.

References GrowingArrayBase::Len(), and sendBuffer_.

Referenced by nNetObject::SyncAll().

00178                                                  {
00179         return sendBuffer_.Len();    // returns the length of the buffer
00180     }

Here is the call graph for this function:

Here is the caller graph for this function:

void nSendBuffer::AddMessage ( nMessage message,
nBandwidthControl control 
)

Definition at line 1893 of file nNetwork.cpp.

References tRecorderSync< DATA >::Archive(), nMessage::Data(), nMessage::DataLen(), nMessage::Descriptor(), GrowingArrayBase::Len(), nMessage::MessageID(), sendBuffer_, nBandwidthControl::Usage_Planning, and nBandwidthControl::Use().

Referenced by nBandwidthTaskMessage::DoExecute(), nBandwidthTaskCreate::DoExecute(), nBandwidthTaskSync::DoExecute(), and nMessage::SendImmediately().

01896 {
01897     unsigned long id = message.MessageID();
01898     unsigned short len = message.DataLen();
01899     tRecorderSync< unsigned long >::Archive( "_MESSAGE_ID_SEND", 5, id );
01900 
01901     sendBuffer_[sendBuffer_.Len()]=htons(message.Descriptor());
01902 
01903     sendBuffer_[sendBuffer_.Len()]=htons(message.MessageID());
01904 
01905     sendBuffer_[sendBuffer_.Len()]=htons(message.DataLen());
01906     for(int i=0;i<len;i++)
01907         sendBuffer_[sendBuffer_.Len()]=htons(message.Data(i));
01908 
01909     tRecorderSync< unsigned short >::Archive( "_MESSAGE_SEND_LEN", 5, len );
01910 
01911     if ( control )
01912     {
01913         control->Use( nBandwidthControl::Usage_Planning, len * 2 );

Here is the call graph for this function:

Here is the caller graph for this function:

void nSendBuffer::Send ( nSocket const &  socket,
const nAddress peer,
nBandwidthControl control 
)

Definition at line 1916 of file nNetwork.cpp.

References Clear(), GrowingArrayBase::Len(), OVERHEAD, sendBuffer_, nBandwidthControl::Usage_Execution, nBandwidthControl::Use(), and nSocket::Write().

01921 {
01922     if (sendBuffer_.Len()){
01923         sn_SentPackets++;
01924         sn_SentBytes  += sendBuffer_.Len() * 2 + OVERHEAD;
01925 
01926         // store our id
01927         sendBuffer_[sendBuffer_.Len()]=htons(::sn_myNetID);
01928 
01929         socket.Write( reinterpret_cast<int8 *>(&(sendBuffer_[0])),
01930                       2*sendBuffer_.Len(), peer);
01931 
01932         if ( control )
01933         {
01934             control->Use( nBandwidthControl::Usage_Execution, 2*sendBuffer_.Len() + OVERHEAD );
01935         }
01936 
01937         this->Clear();

Here is the call graph for this function:

void nSendBuffer::Broadcast ( nSocket const &  socket,
int  port,
nBandwidthControl control 
)

Definition at line 1940 of file nNetwork.cpp.

References nSocket::Broadcast(), Clear(), GrowingArrayBase::Len(), OVERHEAD, sendBuffer_, nBandwidthControl::Usage_Execution, and nBandwidthControl::Use().

Referenced by nMessage::BroadcastCollected().

01945 {
01946     if (sendBuffer_.Len()){
01947         sn_SentPackets++;
01948         sn_SentBytes  += sendBuffer_.Len() * 2 + OVERHEAD;
01949 
01950         // store our id
01951         sendBuffer_[sendBuffer_.Len()]=htons(::sn_myNetID);
01952 
01953         socket.Broadcast( reinterpret_cast<int8 *>(&(sendBuffer_[0])),
01954                           2*sendBuffer_.Len(), port);
01955 
01956         Clear();
01957 
01958         if ( control )
01959         {
01960             control->Use( nBandwidthControl::Usage_Execution, 2*sendBuffer_.Len() + OVERHEAD );
01961         }

Here is the call graph for this function:

Here is the caller graph for this function:

void nSendBuffer::Clear ( void   ) 

Definition at line 1964 of file nNetwork.cpp.

References GrowingArrayBase::Len(), sendBuffer_, and tArray< T, MALLOC >::SetLen().

Referenced by Broadcast(), and Send().

01967 {
01968     for(int i=sendBuffer_.Len()-1;i>=0;i--)
01969         sendBuffer_(i)=0;
01970 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tArray<unsigned short> nSendBuffer::sendBuffer_ [private]

Definition at line 194 of file nNetwork.h.

Referenced by AddMessage(), Broadcast(), Clear(), Len(), and Send().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:49:23 2008 for Armagetron Advanced by  doxygen 1.5.4