Receive and dispatch packets. * @return the number of packets received */
| 695 | * @return the number of packets received |
| 696 | */ |
| 697 | size_t NetworkSequenceCollection::pumpNetwork() |
| 698 | { |
| 699 | for (size_t count = 0; ; count++) { |
| 700 | int senderID; |
| 701 | APMessage msg = m_comm.checkMessage(senderID); |
| 702 | switch(msg) |
| 703 | { |
| 704 | case APM_CONTROL: |
| 705 | parseControlMessage(senderID); |
| 706 | // Deal with the control packet before we continue |
| 707 | // processing further packets. |
| 708 | return ++count; |
| 709 | case APM_BUFFERED: |
| 710 | { |
| 711 | MessagePtrVector msgs; |
| 712 | m_comm.receiveBufferedMessage(msgs); |
| 713 | for (MessagePtrVector::iterator |
| 714 | iter = msgs.begin(); |
| 715 | iter != msgs.end(); iter++) { |
| 716 | // Handle each message based on its type |
| 717 | (*iter)->handle(senderID, *this); |
| 718 | // Delete the message |
| 719 | delete (*iter); |
| 720 | *iter = 0; |
| 721 | } |
| 722 | break; |
| 723 | } |
| 724 | case APM_NONE: |
| 725 | return count; |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | /** Call the observers of the specified sequence. */ |
| 731 | void NetworkSequenceCollection::notify(const V& key) |
no test coverage detected