ping static method
Manual ping to check WebSocket connection.
Migration Note: Migrated from platform channels to native Dart implementation. Uses RealtimeRepository for manual ping. Behavior and signature remain identical for backward compatibility.
Android Reference: CometChat.ping(CallbackListener<String> listener)
Implementation
static Future<void> ping(
{required Function? onSuccess,
required Function(CometChatException e)? onError}) async {
try {
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call native Dart realtime repository
await sdk.realtime.ping();
// Call success callback
if (onSuccess != null) onSuccess();
} on SdkException catch (sdkEx) {
// Convert SdkException to CometChatException
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} on CometChatException catch (cce) {
// Already a CometChatException
_errorCallbackHandler(cce, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
}