Method | Description | |
---|---|---|
GetChunk ( |
Method used to request the download of a chunk from the network. When it is invoked from a remote peer it gets the chunk from the file and calls back the ReturnChunk method of the requestor.
|
|
ReStart ( ) : void |
Method used to restart the download without reinitializing the buffer and other inner structures.
|
|
ReturnChunk ( |
Method used to return chunk to requestors. When it is invoked from a remote peer it invokes the saveOnBuffer method to store the chunk into the buffer. At the end this method reset the peer status.
|
|
Start ( string RID, int begin, long length, float>.Dictionary |
Start method of the class. This method allows the thread to start the procedure of download of a remote resource in a separate thread. It initialize all attributes related to the resource.
|
|
Stop ( ) : void |
Method used to stop the download.
|
|
TransportProtocol ( |
Constructor of the class. It builds the TransportProtocol sublayer, initializing its common attributes using the app settings in xml file.
|
Method | Description | |
---|---|---|
doWork ( ) : void |
Method that actively downloads the resource from the network. This method runs while the file is not completely downloaded or a stop have been requested.
|
|
fullyDownloaded ( ) : bool |
Method used to understand at each step if the download is complete. The download is complete when the number of chunk in DOWNLOADED state is equal to the size of buffer.
|
|
getNextChunk ( ) : void |
Method used to require the next chunk to the network. It selects the best peer to whom ask the chunk, it calculates the next chunk to get and then invokes the chunk from the remote peer.
|
|
getRemoteChunk ( |
Method used to require the chunk to the remote peer.
|
|
nextChunkToGet ( ) : int |
Method used to find the index of the next chunk to get from the network.
|
|
saveOnBuffer ( int CID, byte payload ) : void |
Method used to save the chunk arrived to the buffer inside the object. If the chunk arrived is the waited chunk, the nextArrived event is released. If the chunk arrived have an identificator greater to the waited the chunk is buffered and then all chunks in dirty state between the waited chunk and the arrived chunk is set to CLEAN state.
|
|
writeOnStream ( Object o, |
Method having a signature that match the one required by delegate to execute. This method is used to write the newly arrived chunk to the stream. If the chunk enables other following chunks to been written to the stream the method itself writes the other chunks to the stream.
|
public GetChunk ( |
||
chkrq | Message used to pass information about the Chunk requested | |
return | void |
public ReturnChunk ( |
||
chkrs | Message used to transport the payload of a chunk | |
return | void |
public Start ( string RID, int begin, long length, float>.Dictionary |
||
RID | string | Identificator of the resource |
begin | int | Start point from the beginning of the file to begin download |
length | long | >Total length in bytes of the resource |
peerQueue | float>.Dictionary | PeerQueue of peers containing the resource with a score associated to each peer |
s | Stream | Stream where the resource is written |
return | void |
public TransportProtocol ( |
||
uri | The URI of the transport layer | |
trackRepository | Persistence | The repository used to represent tracks over the network |
return | System |