All Superinterfaces:
Feature

public interface Pings extends Feature
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.

Accessing the feature

This feature may be obtained from a session, and used as follows:
 Pings pings = session.feature(Pings.class);

 CompletableFuture<PingDetails> response = pings.pingServer();

 PingDetails result = response.get();  // Block for response

 System.out.printf("Round-trip call to server took %d milliseconds%n", result.getRoundTripTime());
 

Alternatively, the CompletableFuture API can be used to process the result using the Diffusion input thread, without blocking the calling thread:

 Pings pings = session.feature(Pings.class);

 pings.pingServer()
      .thenApply(PingDetails::getRoundTripTime)
      .thenAccept(t -> System.out.printf("Round-trip call to server took %d milliseconds%n", t));
 
Since:
5.0
Author:
DiffusionData Limited
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Server response to a ping.
  • Method Summary

    Modifier and Type
    Method
    Description
    Send a ping request to the server.

    Methods inherited from interface com.pushtechnology.diffusion.client.session.Feature

    getSession
  • Method Details

    • pingServer

      Send a ping request to the server.
      Returns:
      a CompletableFuture that completes when a response is received from the server

      If the ping was successful, the CompletableFuture will complete successfully. The result is a Pings.PingDetails containing timing information.

      Otherwise, the CompletableFuture will complete exceptionally with a CompletionException. Common reasons for failure, listed by the exception reported as the cause, include:

      Since:
      6.0