#include <PeerList.h>
Inherits CLockMechanism.
Public Member Functions | |
CPeerList () | |
virtual | ~CPeerList () |
UINT32 | getLastError () |
Returns last error code happened. | |
bool | add (UINT32 ip, UINT16 port) |
bool | remove (UINT32 ip, UINT16 port) |
bool | removeAll () |
bool | isAllowed (UINT32 ip, UINT16 port) |
bool | getReceivePacketIndex (UINT32 ip, UINT16 port, UINT16 &packetindex) |
bool | setReceivePacketIndex (UINT32 ip, UINT16 port, UINT16 packetindex) |
bool | getSendPacketIndex (UINT32 ip, UINT16 port, UINT16 &aNextPacketIndex) |
bool | incSendPacketIndex (UINT32 ip, UINT16 port) |
UINT32 | count () |
Returns the number of elements (number of peers) in the peer list. | |
bool | add (UINT32 ip, UINT16 port, UINT32 &lasterr) |
adds a new peer to the list of peers. | |
bool | remove (UINT32 ip, UINT16 port, UINT32 &lasterr) |
Removes a peer from the list of peers. | |
bool | removeAll (UINT32 &lasterr) |
Clears the list of peers (makes it empty). | |
bool | isAllowed (UINT32 ip, UINT16 port, UINT32 &lasterr) |
Checks whether a peer is in the list. | |
bool | getReceivePacketIndex (UINT32 ip, UINT16 port, UINT16 &packetindex, UINT32 &lasterr) |
bool | setReceivePacketIndex (UINT32 ip, UINT16 port, UINT16 packetindex, UINT32 &lasterr) |
bool | getSendPacketIndex (UINT32 ip, UINT16 port, UINT16 &aNextPacketIndex, UINT32 &lasterr) |
Returns the index of the last packet that was send to the peer. | |
bool | incSendPacketIndex (UINT32 ip, UINT16 port, UINT32 &lasterr) |
Increments the packet index for given peer. | |
Private Attributes | |
INT32 | m_iQueueFirstElement |
INT32 | m_iQueueLastElement |
INT32 | m_iQueueNumElements |
PEER_ENTRY_INT * | m_pQueueValue |
INT32 * | m_iQueueNextElement |
INT32 | m_iQueueMaxSize |
UINT32 | m_iLastError |
Definition at line 42 of file PeerList.h.
CPeerList::CPeerList | ( | ) |
Definition at line 12 of file PeerList.cpp.
CPeerList::~CPeerList | ( | ) | [virtual] |
Definition at line 38 of file PeerList.cpp.
UINT32 CPeerList::getLastError | ( | ) |
Returns last error code happened.
For detailed list of possible error codes, see Declarations.h
Definition at line 752 of file PeerList.cpp.
bool CPeerList::add | ( | UINT32 | ip, | |
UINT16 | port | |||
) |
Definition at line 50 of file PeerList.cpp.
Referenced by CNetworkQueue::addPeer(), and CNetworkQueue::create().
bool CPeerList::remove | ( | UINT32 | ip, | |
UINT16 | port | |||
) |
Definition at line 57 of file PeerList.cpp.
Referenced by CNetworkQueue::removePeer().
bool CPeerList::removeAll | ( | ) |
Definition at line 64 of file PeerList.cpp.
Referenced by CNetworkQueue::create().
bool CPeerList::isAllowed | ( | UINT32 | ip, | |
UINT16 | port | |||
) |
Definition at line 87 of file PeerList.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask(), CNetworkQueue::sendMsgTo(), and CNetworkQueue::sendMsgToInternal().
bool CPeerList::getReceivePacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 & | packetindex | |||
) |
Definition at line 94 of file PeerList.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask().
bool CPeerList::setReceivePacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 | packetindex | |||
) |
Definition at line 101 of file PeerList.cpp.
Referenced by CNetworkQueue::ReceiveProcessTask().
bool CPeerList::getSendPacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 & | aNextPacketIndex | |||
) |
Definition at line 108 of file PeerList.cpp.
Referenced by CNetworkQueue::SendProcessTask().
bool CPeerList::incSendPacketIndex | ( | UINT32 | ip, | |
UINT16 | port | |||
) |
Definition at line 115 of file PeerList.cpp.
Referenced by CNetworkQueue::SendProcessTask().
UINT32 CPeerList::count | ( | ) |
Returns the number of elements (number of peers) in the peer list.
Definition at line 377 of file PeerList.cpp.
bool CPeerList::add | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT32 & | lasterr | |||
) |
adds a new peer to the list of peers.
ip | ip address of peer to add in host byte order | |
port | network port of peer to add in host byte order | |
lasterr | unique error code |
true | successful, element appended OR element was already inside | |
false | failure, something happened (see lasterr) |
This
method contains assert() which gives more failure reasons during development/debugging.Definition at line 148 of file PeerList.cpp.
bool CPeerList::remove | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT32 & | lasterr | |||
) |
Removes a peer from the list of peers.
ip | ip address of peer to remove in host byte order | |
port | network port of peer to remove in host byte order | |
lasterr | unique error code |
true | successful, element removed | |
false | failure, something happened (see lasterr)
|
Definition at line 260 of file PeerList.cpp.
bool CPeerList::removeAll | ( | UINT32 & | lasterr | ) |
Clears the list of peers (makes it empty).
lasterr | unique error code |
true | successful, peer list is empty now | |
false | failure, something happened (see lasterr)
|
Definition at line 345 of file PeerList.cpp.
bool CPeerList::isAllowed | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT32 & | lasterr | |||
) |
Checks whether a peer is in the list.
This method checks whether a peer (defined as (ip, port)) is inside the list (and thus, it is allowed to receive packets from and send packets to the peer)
ip | ip address of peer to check in host byte order | |
port | network port of peer to check in host byte order | |
lasterr | unique error code |
true | successful, peer is in the list and thus allowed | |
false | peer is not allowed; failure, something happened (see lasterr)
|
Definition at line 482 of file PeerList.cpp.
bool CPeerList::getReceivePacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 & | packetindex, | |||
UINT32 & | lasterr | |||
) |
Returns received packet index from given peer.
This method returns the last received packet index that came from the peer, IF there was already a packet received from that peer.
ip | ip address of peer in host byte order | |
port | network port of peer in host byte order | |
packetindex | last packet index from peer (on true return code) | |
lasterr | unique error code |
true | successful, packetindex is returned | |
false | failure, something happened (see lasterr)
|
Definition at line 538 of file PeerList.cpp.
bool CPeerList::setReceivePacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 | packetindex, | |||
UINT32 & | lasterr | |||
) |
Returns the last received packet index from given peer.
This method returns the last received packet index that came from the peer, IF there was already a packet received from that peer.
ip | ip address of peer in host byte order | |
port | network port of peer in host byte order | |
packetindex | last packet index from peer (to save inside peerlist) | |
lasterr | unique error code |
true | successful, packetindex was updated inside peerlist | |
false | failure, something happened (see lasterr)
|
Definition at line 602 of file PeerList.cpp.
bool CPeerList::getSendPacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT16 & | aNextPacketIndex, | |||
UINT32 & | lasterr | |||
) |
Returns the index of the last packet that was send to the peer.
ip | ip address of peer in host byte order | |
port | network port of peer in host byte order | |
aNextPacketIndex | last send packet index to peer (on true return code) | |
lasterr | unique error code |
true | successful, last send packet index is returned | |
false | failure, something happened (see lasterr)
|
Definition at line 657 of file PeerList.cpp.
bool CPeerList::incSendPacketIndex | ( | UINT32 | ip, | |
UINT16 | port, | |||
UINT32 & | lasterr | |||
) |
Increments the packet index for given peer.
This method increments the send packet index of the given peer (because a packet was successfully send out by the network queue) by one.
ip | ip address of peer in host byte order | |
port | network port of peer in host byte order | |
lasterr | unique error code |
true | successful, send packet index was incremented (by one) | |
false | failure, something happened (see lasterr)
|
Definition at line 712 of file PeerList.cpp.
INT32 CPeerList::m_iQueueFirstElement [private] |
Definition at line 83 of file PeerList.h.
Referenced by add(), CPeerList(), getReceivePacketIndex(), getSendPacketIndex(), incSendPacketIndex(), isAllowed(), remove(), removeAll(), and setReceivePacketIndex().
INT32 CPeerList::m_iQueueLastElement [private] |
Definition at line 84 of file PeerList.h.
Referenced by add(), CPeerList(), remove(), and removeAll().
INT32 CPeerList::m_iQueueNumElements [private] |
Definition at line 85 of file PeerList.h.
Referenced by add(), count(), CPeerList(), remove(), and removeAll().
PEER_ENTRY_INT* CPeerList::m_pQueueValue [private] |
Definition at line 88 of file PeerList.h.
Referenced by add(), CPeerList(), getReceivePacketIndex(), getSendPacketIndex(), incSendPacketIndex(), isAllowed(), remove(), removeAll(), setReceivePacketIndex(), and ~CPeerList().
INT32* CPeerList::m_iQueueNextElement [private] |
Definition at line 89 of file PeerList.h.
Referenced by add(), CPeerList(), getReceivePacketIndex(), getSendPacketIndex(), incSendPacketIndex(), isAllowed(), remove(), removeAll(), setReceivePacketIndex(), and ~CPeerList().
INT32 CPeerList::m_iQueueMaxSize [private] |
UINT32 CPeerList::m_iLastError [private] |
Definition at line 93 of file PeerList.h.
Referenced by add(), CPeerList(), getLastError(), getReceivePacketIndex(), getSendPacketIndex(), incSendPacketIndex(), isAllowed(), remove(), removeAll(), and setReceivePacketIndex().