GWebCache 1.0.0-alpha
C# library and nuget package to interact with a Gnutella Webcache
Loading...
Searching...
No Matches
GWebCache.GWebCacheClient Class Reference

Concrete implementation of IGWebCacheClient More...

Inheritance diagram for GWebCache.GWebCacheClient:
GWebCache.IGWebCacheClient

Public Member Functions

 GWebCacheClient (string host, GWebCacheClientConfig? config=null)
 Constructor for the GWebCacheClient.
 
bool CheckIfAlive ()
 Preforms a ping request to the server to check if it is alive.
 
Result< PongResponsePing ()
 Preforms a ping request to the webcache. Mainly used to check if the server is alive.
 
Result< StatFileResponseGetStats ()
 Returns the stats of the webcache server.
 
Result< HostfileResponseGetHostfile (GnutellaNetwork? gnutellaNetwork=null)
 Retrieves a list of Gnutella Nodes from the webcache.
 
Result< UrlFileResponseGetUrlFile (GnutellaNetwork? network=null)
 Retrieves a list of Urls to other webcaches from the webcache.
 
Result< UpdateResponseUpdate (UpdateRequest updateRequest)
 Sends an Update request to the webcache. Indicating a new gnutella node, or webcache url or both.
 
Result< GetResponseGet (GnutellaNetwork? network)
 Retrieves a list of Gnutella Nodes and webcache urls from a V2 webache. This is only valid on a V2 cache!
 
bool WebCacheIsV2 ()
 Returns the property GWebCacheClientConfig.IsV2
 

Detailed Description

Concrete implementation of IGWebCacheClient

Constructor & Destructor Documentation

◆ GWebCacheClient()

GWebCache.GWebCacheClient.GWebCacheClient ( string host,
GWebCacheClientConfig? config = null )
inline

Constructor for the GWebCacheClient.

Parameters
hostThe url of the webcache in string format
configOptional configuration object
Exceptions
ArgumentExceptionIf the url can't be parsed an argument exception is thrown

It's recommended that you use http even if the webcache supports https.

The constructor will invoke the default configuration if not specified GWebCacheClientConfig

The constructor will also check if the webcache is a V2 webcache in case it's not explicitely provided in the configuration

DetermineIfCacheIsV2

Member Function Documentation

◆ CheckIfAlive()

bool GWebCache.GWebCacheClient.CheckIfAlive ( )
inline

Preforms a ping request to the server to check if it is alive.

Returns
Boolean indicating if the server succesfully anwsered the ping request

A succesfull pong response is defined in PongResponse

Ping

See also
PongResponse

Implements GWebCache.IGWebCacheClient.

◆ Get()

Result< GetResponse > GWebCache.GWebCacheClient.Get ( GnutellaNetwork? network)
inline

Retrieves a list of Gnutella Nodes and webcache urls from a V2 webache. This is only valid on a V2 cache!

Parameters
networkThe network you want to get the nodes and webcache urls from.
Returns
A Result with GetResponse

GetResponse

See also
Result<T>, GnutellaNetwork, GWebCacheNode

Implements GWebCache.IGWebCacheClient.

◆ GetHostfile()

Result< HostfileResponse > GWebCache.GWebCacheClient.GetHostfile ( GnutellaNetwork? network = null)
inline

Retrieves a list of Gnutella Nodes from the webcache.

Parameters
networkThe network you want to get the nodes from. Will not be specified by default.
Returns
A Result with HostFileResponse

V1 caches typically don't include gnutella 2 or the network parameter. However they will ignore it so it's always best to specify.

You can use this method on both versions. It is however recommended to use the Get(GnutellaNetwork?) method for version 2 of the specification.

<example

IGWebCacheClient client = new GWebCacheClient("url");
client.GetHostfile(GnutellaNetwork.Gnutella2);
GWebCacheClient(string host, GWebCacheClientConfig? config=null)
Constructor for the GWebCacheClient.
Definition GWebCacheClient.cs:27
Client for interacting with a GWebCache server. Supports Version 1 and 2 of the protocol.
Definition IGWebCacheClient.cs:12
Result< HostfileResponse > GetHostfile(GnutellaNetwork? network=null)
Retrieves a list of Gnutella Nodes from the webcache.
GnutellaNetwork
There's two versions of Gnutella V1 and V2 some methods require you to specify which version is used....
Definition GnutellaNetwork.cs:6

Result<T>

See also
HostfileResponse, GnutellaNetwork, Get(GnutellaNetwork?), GnutellaNode

Implements GWebCache.IGWebCacheClient.

◆ GetStats()

Result< StatFileResponse > GWebCache.GWebCacheClient.GetStats ( )
inline

Returns the stats of the webcache server.

Returns
A Result with StatFileResponse

Not all webcache servers actually implement this. So don't assume you will get a successfull result.

Result<T>

See also
StatFileResponse

Implements GWebCache.IGWebCacheClient.

◆ GetUrlFile()

Result< UrlFileResponse > GWebCache.GWebCacheClient.GetUrlFile ( GnutellaNetwork? network = null)
inline

Retrieves a list of Urls to other webcaches from the webcache.

Parameters
networkThe network you want to get the nodes from. Will not be specified by default.
Returns
A Result with UrlFileResponse

While the network parameter doesn't make a difference in V2 caches a lot of them require it and will return the same result regardless.

IGWebCacheClient client = new GWebCacheClient("url");
client.GetUrlFile(GnutellaNetwork.Gnutella2);
Result< UrlFileResponse > GetUrlFile(GnutellaNetwork? network=null)
Retrieves a list of Urls to other webcaches from the webcache.

UrlFileResponse

See also
Result<T>, GnutellaNetwork, GWebCacheNode

Implements GWebCache.IGWebCacheClient.

◆ Ping()

Result< PongResponse > GWebCache.GWebCacheClient.Ping ( )
inline

Preforms a ping request to the webcache. Mainly used to check if the server is alive.

Returns
A Result with Pongresponse

Result<T>

See also
PongResponse

Implements GWebCache.IGWebCacheClient.

◆ Update()

Result< UpdateResponse > GWebCache.GWebCacheClient.Update ( UpdateRequest updateRequest)
inline

Sends an Update request to the webcache. Indicating a new gnutella node, or webcache url or both.

Returns
A Result with UpdateResponse

Note that there's a network parameter in the update request.

The update response might also contain warnings when for example you're being rate limited.

IGWebCacheClient client = new GWebCacheClient("V2 url");
GnutellaNode node = GnutellaNode("ip", port);
GWebCacheNode webCache = new GWebCacheNode("url");
UpdateRequest updateRequest = new UpdateRequest() {
GnutellaNode = node,
GWebCacheNode = webCache,
Network = GnutellaNetwork.Gnutella2
};
client.Update(updateRequest);
A model representing a webcache.
Definition GWebCacheNode.cs:7
The model representing a Gnutella node on the network stored in the cache.
Definition GnutellaNode.cs:9
Request model to update the webcache with a new gnutella node or a WebCache Url.
Definition UpdateRequest.cs:11
Result< UpdateResponse > Update(UpdateRequest updateRequest)
Sends an Update request to the webcache. Indicating a new gnutella node, or webcache url or both.

UpdateResponse" <seealso cref="Result{T}"/> <seealso cref="UpdateRequest"/> <seealso cref="GnutellaNode"/> <seealso cref="GWebCacheNode"/>

Implements GWebCache.IGWebCacheClient.

◆ WebCacheIsV2()

bool GWebCache.GWebCacheClient.WebCacheIsV2 ( )
inline

Returns the property GWebCacheClientConfig.IsV2

If this property wasn't specified, a ping request is made when creating the client to fill in this property.

GWebCacheClientConfig.IsV2

See also
Ping

Implements GWebCache.IGWebCacheClient.


The documentation for this class was generated from the following file: