Just a second...

Pinging the Diffusion server

Ping the Diffusion™ server from your client. If the ping is successful it reports the round-trip time between your client and the Diffusion server.

The Diffusion client libraries and the Diffusion server include capabilities that automatically check whether the connection is active. However, there might be times when you want to check the connection from within your client code. For example, if the client is aware that the device it is hosted on has recently changed from a 3G connection to a WiFi connection.

Use the pings capability to asynchronously ping the Diffusion server.

const pingResult=await session.pingServer();
// Take action based on ping details.

IPings pings = session.Ping;
pings.PingServer( context, callback );
Java and Android
Pings pings = session.feature(Pings.class);
pings.pingServer(context, callback);
static int on_ping_response(SESSION_T *session, void *context)
        // ping response received
        return HANDLER_SUCCESS;

void ping(SESSION_T *session)
        PING_USER_PARAMS_T params = {
                .on_ping_response = on_ping_response
        ping_user(session, params);
//  Copyright (C) 2021 Push Technology Ltd.
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//  http://www.apache.org/licenses/LICENSE-2.0
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.

import Foundation
import Diffusion

class Pinging {

    func ping(session: PTDiffusionSession) {
        session.pings.pingServer { (ping_details, error) in

            // Check error is `nil`, indicating success.
            if (error != nil) {
                print("An error occurred while pinging the server: %@", error!.localizedDescription)

            print("Ping round trip time: %@", ping_details!.roundTripTime)