C# Class PeerLibrary.Peer

Inheritance: IDisposable, IPeer
Exibir arquivo Open project: zencoders/sambatyon Class Usage Examples

Public Methods

Method Description
Configure ( string udpPort = "-1", string kademliaPort = "-1" ) : void

PeerLibrary.IPeer

ConnectToStream ( ) : Stream

PeerLibrary.IPeer

Dispose ( ) : void

Method created to implement the IDisposable interface and used to close all service hosts already running.

GetAllTracks ( ) : IList

Method used to get all stored tracks

GetFlow ( string RID, int begin, long length, float>.Dictionary nodes ) : void

PeerLibrary.IPeer

GetFlow ( string RID, int begin, long length, float>.Dictionary nodes, Stream stream = null ) : void

Overload of the previous method with an extern stream passed.

Peer ( bool single = false, string btpNode = "" ) : System

Peer Constructor. It initialize configuration according to the options passed, initialize the local stream, creates the databases and resolves the IP address using Dns class.

RestartFlow ( ) : void

PeerLibrary.IPeer

RunLayers ( bool withoutInterface = false ) : void

Method used to run layers (kademlia, transport, interface). Each layer is ran in a separate thread in order to allow to register the thread hosting the service with a referrer thread id (in global threadpool) that is different from the mai thread. The method will wait each layer to have completely finished booting before passing to another layer.

SearchFor ( string queryString ) : IList

PeerLibrary.IPeer

StopFlow ( ) : void

PeerLibrary.IPeer

StoreFile ( string filename ) : bool

PeerLibrary.IPeer

Private Methods

Method Description
calculateAddresses ( ) : void

Method used to construct all local addresses according to configuration.

runInterfaceLayer ( System.ServiceModel.ServiceHost &svcHost ) : void

Method (usually runned like a thread) that privately hosts the interface service.

runKademliaLayer ( bool single, string btpNode, System.ServiceModel.ServiceHost &svcHost ) : void

Method that runs the kademlia layer

runTransportLayer ( System.ServiceModel.ServiceHost &svcHost ) : void

Method that runs the transport layer

Method Details

Configure() public method

PeerLibrary.IPeer
public Configure ( string udpPort = "-1", string kademliaPort = "-1" ) : void
udpPort string String containing the value of the udpPort
kademliaPort string String containig the value of the kademliaPort
return void

ConnectToStream() public method

PeerLibrary.IPeer
public ConnectToStream ( ) : Stream
return Stream

Dispose() public method

Method created to implement the IDisposable interface and used to close all service hosts already running.
public Dispose ( ) : void
return void

GetAllTracks() public method

Method used to get all stored tracks
public GetAllTracks ( ) : IList
return IList

GetFlow() public method

PeerLibrary.IPeer
public GetFlow ( string RID, int begin, long length, float>.Dictionary nodes ) : void
RID string The resource identifier
begin int The begin point from the head of a file to start download
length long The total length of file
nodes float>.Dictionary Nodes with associated score that are used to download a file from the network
return void

GetFlow() public method

Overload of the previous method with an extern stream passed.
public GetFlow ( string RID, int begin, long length, float>.Dictionary nodes, Stream stream = null ) : void
RID string The resource identifier
begin int The begin point from the head of a file to start download
length long The total length of file
nodes float>.Dictionary Nodes with associated score that are used to download a file from the network
stream Stream The stream to use
return void

Peer() public method

Peer Constructor. It initialize configuration according to the options passed, initialize the local stream, creates the databases and resolves the IP address using Dns class.
public Peer ( bool single = false, string btpNode = "" ) : System
single bool Indicates if the peer have to run kademlia layer in single bootstrap
btpNode string Address of the suggested bootstrap node.
return System

RestartFlow() public method

PeerLibrary.IPeer
public RestartFlow ( ) : void
return void

RunLayers() public method

Method used to run layers (kademlia, transport, interface). Each layer is ran in a separate thread in order to allow to register the thread hosting the service with a referrer thread id (in global threadpool) that is different from the mai thread. The method will wait each layer to have completely finished booting before passing to another layer.
public RunLayers ( bool withoutInterface = false ) : void
withoutInterface bool indicates whether to start or not the peer interface layer.
return void

SearchFor() public method

PeerLibrary.IPeer
public SearchFor ( string queryString ) : IList
queryString string the querystring used to search
return IList

StopFlow() public method

PeerLibrary.IPeer
public StopFlow ( ) : void
return void

StoreFile() public method

PeerLibrary.IPeer
public StoreFile ( string filename ) : bool
filename string filename of the file to download
return bool