Diffusion .NET Client Library  6.1.5
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
PushTechnology.ClientInterface.Client.Features.IPings Interface Reference

This feature provides a client session with the ability to test its connection to the server. More...

Inheritance diagram for PushTechnology.ClientInterface.Client.Features.IPings:
PushTechnology.ClientInterface.Client.Features.IFeature

Public Member Functions

Task< IPingDetailsPingServerAsync ()
 Sends a ping request to the server. More...
 
Task< IPingDetailsPingServerAsync (CancellationToken cancellationToken)
 Sends a ping request to the server. More...
 
void PingServer (IPingCallback callback)
 Sends a ping request to the server. More...
 
void PingServer< TContext > (TContext context, IPingContextCallback< TContext > callback)
 Sends a ping request to the server. More...
 

Additional Inherited Members

- Properties inherited from PushTechnology.ClientInterface.Client.Features.IFeature
ISession Session [get]
 Returns the session that the feature is associated with. More...
 

Detailed Description

This feature provides a client session with the ability to test its connection to the server.

The main purpose of a ping is to test, at a very basic level, the current network conditions that exist between the client session and the server it is connected to. The ping response includes the time taken to make a round-trip call to the server.

Access Control:

There are no permissions requirements associated with this feature.

Since 5.0

This example shows how to access the pings feature from a Session.ISession and ping the server.

// Accessing the feature.
var pings = session.Ping;
// Pinging the server and waiting for the result.
// This operation will block until the ping details have
// been received.
var details = pings.PingServerAsync().Result;
// Any exceptions thrown within the PingServerAsync()
// method will be packed into an AggregateException.
try {
var details = pings.PingServerAsync().Result;
} catch ( AggregateException ae ) {
ae.Handle( ex => {
// Handle specific exception in here.
return true; // Exception is handled.
} );
}
// Pinging the server in a async/await scenario.
var details = await pings.PingServerAsync();
// Exceptions in an async/await scenario will not
// be bundled into an AggregateException so they
// have to be handled in the usual way.
try {
var details = await pings.PingServerAsync();
} catch ( SessionClosedException ex ) {
// Handle session closed exception.
}
// The await/async pattern is the preferred way to
// use the IPings feature. For more information visit:
// https://msdn.microsoft.com/en-gb/library/mt674882.aspx

Member Function Documentation

void PushTechnology.ClientInterface.Client.Features.IPings.PingServer ( IPingCallback  callback)

Sends a ping request to the server.

Parameters
callbackThe callback for the response to this ping operation.
Exceptions
ArgumentNullExceptionThe callback is null.
void PushTechnology.ClientInterface.Client.Features.IPings.PingServer< TContext > ( TContext  context,
IPingContextCallback< TContext >  callback 
)

Sends a ping request to the server.

Template Parameters
TContextThe context type.
Parameters
contextThe context object that will be passed to the callback.
callbackThe callback for the response to this ping operation.
Exceptions
ArgumentNullExceptionThe callback is null.
Task<IPingDetails> PushTechnology.ClientInterface.Client.Features.IPings.PingServerAsync ( )

Sends a ping request to the server.

Since 6.0

Returns
The task representing the current operation.
Exceptions
Session.SessionClosedExceptionThe session is closed. Thrown by the returned task.
See Also
PingServerAsync(CancellationToken)
Task<IPingDetails> PushTechnology.ClientInterface.Client.Features.IPings.PingServerAsync ( CancellationToken  cancellationToken)

Sends a ping request to the server.

Since 6.0

Parameters
cancellationTokenThe cancellation token used to cancel the current operation.
Returns
The task representing the current operation.
Exceptions
Session.SessionClosedExceptionThe session is closed. Thrown by the returned task.

Pinging the server with a CancellationToken

try {
var src = new CancellationTokenSource();
var details = await session.Ping.PingServerAsync( src.Token );
} catch ( SessionClosedException ex ) {
Console.WriteLine( $"Ping failed. Reason: {ex}." );
}

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