Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 14, 2007, 2:58:23 PM (16 years ago)
Author:
scheusso
Message:

changed packetbuffer and conenctionmanager to remember the client id/adjustet dummyserver/client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/PacketBuffer.cc

    r196 r204  
    2121 
    2222
    23 bool PacketBuffer::push(ENetPacket *pck){
     23bool PacketBuffer::push(ENetEvent *ev){
    2424  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
    2525//   if(closed)
    2626//     return false;
    27   // also works if fifo is null (queue empty)
    28   // just to be sure last is really the last element
    29   /*if(last!=NULL)
    30     while(last->next!=NULL)
    31       last=last->next;*/
    3227  // first element?
    3328  if(first==NULL){
     
    3631    last->next=NULL;
    3732    // change this!!!!!!!
    38     last->packet = pck;
     33    last->packet = ev->packet;
     34    last->address = ev->peer->address;
    3935    } else {
    4036    //insert a new element at the bottom
     
    4440    last->next=NULL;
    4541    // save the packet to the new element
    46     last->packet = pck;
     42    last->packet = ev->packet;
     43    last->address = ev->peer->address;
    4744  }
    4845  return true;
     
    6461}
    6562
     63ENetPacket *PacketBuffer::pop(ENetAddress &address){
     64  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
     65  if(first!=NULL /*&& !closed*/){
     66    QueueItem *temp = first;
     67    // get packet
     68    ENetPacket *pck=first->packet;
     69    address = first->address;
     70    // remove first element
     71    first = first->next;
     72    delete temp;
     73    return pck;
     74  } else{
     75    return NULL;
     76  }
     77}
     78
    6679bool PacketBuffer::isEmpty(){
    6780  return (first==NULL);
     
    7184  QueueItem *temp=first;
    7285  while(temp!=NULL){
    73     std::cout << temp->packet->data << std::endl;
     86//    std::cout << temp->packet->data << std::endl;
    7487    temp=temp->next;
    7588  }
Note: See TracChangeset for help on using the changeset viewer.