Changeset 204 for code/branches/network/src/network/PacketBuffer.cc
- Timestamp:
- Nov 14, 2007, 2:58:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/PacketBuffer.cc
r196 r204 21 21 22 22 23 bool PacketBuffer::push(ENet Packet *pck){23 bool PacketBuffer::push(ENetEvent *ev){ 24 24 boost::mutex::scoped_lock lock(networkPacketBufferMutex); 25 25 // if(closed) 26 26 // return false; 27 // also works if fifo is null (queue empty)28 // just to be sure last is really the last element29 /*if(last!=NULL)30 while(last->next!=NULL)31 last=last->next;*/32 27 // first element? 33 28 if(first==NULL){ … … 36 31 last->next=NULL; 37 32 // change this!!!!!!! 38 last->packet = pck; 33 last->packet = ev->packet; 34 last->address = ev->peer->address; 39 35 } else { 40 36 //insert a new element at the bottom … … 44 40 last->next=NULL; 45 41 // save the packet to the new element 46 last->packet = pck; 42 last->packet = ev->packet; 43 last->address = ev->peer->address; 47 44 } 48 45 return true; … … 64 61 } 65 62 63 ENetPacket *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 66 79 bool PacketBuffer::isEmpty(){ 67 80 return (first==NULL); … … 71 84 QueueItem *temp=first; 72 85 while(temp!=NULL){ 73 std::cout << temp->packet->data << std::endl;86 // std::cout << temp->packet->data << std::endl; 74 87 temp=temp->next; 75 88 }
Note: See TracChangeset
for help on using the changeset viewer.