C# Класс TransportService.PeerQueueElement

This class represent an abstraction of the peer from the point of view of a requestor. It is used inside a PeerQueue. The class internally stores a channel used to communicate with other peer. It is useful to avoid opening and closing the channel. This class is strictly coupled with PeerQueue.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetChunk ( ChunkRequest chkrq ) : void

Method used to require a chunk to the peer represented by the inner channel.

PeerQueueElement ( ) : System

Default constructor of the class.

PeerQueueElement ( string peerAddress, float peerScore, AutoResetEvent &peerQueueNotEmpty ) : System

Constructor of the class that effectively valorize its attributes.

Reset ( ) : void

Method actively used to reset a peer putting it in free state. If the peer have a timer active the timer is disabled.

TimedPeerBlock ( int millis ) : void

Method used to block the peer (avoid to request again) for a certain number of milliseconds as passed by argument. For the time indicated the peer is put in the BUSY state; after that time the peer is resettled in FREE state.

Приватные методы

Метод Описание
timerHandler ( object source, EventArgs e ) : void

Method called by the timer to automatically call the Reset method. Each time this method is called the peer score is augmented by one.

Описание методов

GetChunk() публичный Метод

Method used to require a chunk to the peer represented by the inner channel.
public GetChunk ( ChunkRequest chkrq ) : void
chkrq TransportService.Messages.ChunkRequest ChunkRequest object containing informations about the resource.
Результат void

PeerQueueElement() публичный Метод

Default constructor of the class.
public PeerQueueElement ( ) : System
Результат System

PeerQueueElement() публичный Метод

Constructor of the class that effectively valorize its attributes.
public PeerQueueElement ( string peerAddress, float peerScore, AutoResetEvent &peerQueueNotEmpty ) : System
peerAddress string URI address of the peer
peerScore float Score of the peer (the less it is the better is the peer
peerQueueNotEmpty System.Threading.AutoResetEvent /// AutoResetEvent used to communicate to the Peer Queue that the queue is not empty. ///
Результат System

Reset() публичный Метод

Method actively used to reset a peer putting it in free state. If the peer have a timer active the timer is disabled.
public Reset ( ) : void
Результат void

TimedPeerBlock() публичный Метод

Method used to block the peer (avoid to request again) for a certain number of milliseconds as passed by argument. For the time indicated the peer is put in the BUSY state; after that time the peer is resettled in FREE state.
public TimedPeerBlock ( int millis ) : void
millis int time used to block the peer.
Результат void