CRecordSessionManagementAvailable
The message SYSTEM
namespace.
This message belongs to the session manager API.
It is part of the kernel.
{ "id": "ed0319bd-b50c-49e1-ade7-d9d7bcb67242", "name": "SESSION_MANAGEMENT_AVAILABLE ", "description": "Broadcast: The session management is now available.", "isService": "true", "namespaces": "SYSTEM", "slots": [ { "key": "av", "name": "IS_AVAILABLE", "direction": "REQUEST", "mandatory": "true", "type": "BOOLEAN", "description": "True: The session management is available." }, { "key": "addr", "name": "ADDRESS", "direction": "REQUEST", "mandatory": "true", "type": "TARGET_ADDRESS", "description": "The address of the session management." } ] }
Usage
Install the observer
The observer for receiving the message is easiest to set up by handling the CRecordStartTarget message. This is the message that every target receives first after registration. Here, we use the RecordHelper. Alternatively, you can retrieve the SYSTEM namespace, then the nanoservice registry, and finally call the addObserver() method.
private boolean asyncStartTarget(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) throws CException { if (aEnvelope.isAnswer()) { return false; } else { // either use the RecordHelper mDependencies.getRecordHelper() .addObserver(CRecordSessionManagementAvailable .class, this, false); // or use the Nanoservice registry mDependencies.getSystemNanoserviceRegistry() .addObserver(CRecordSessionManagementAvailable .class, this, false); // ... aEnvelope.setResultSuccess(); return true; } }
Catch the message
To catch the message, we need a message handler. We add it in the constructor.
// constructor: addMessageHandler(CRecordSessionManagementAvailable .ID, this::asyncSessionManagementAvailable );
private booleanasyncSessionManagementAvailable (@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { return false; } else { final boolean isAvailable =CRecordSessionManagementAvailable .getIsAvailable(aRecord, false); final CTargetAddress sessionManagerAddress =CRecordSessionManagementAvailable .getAddress(aRecord, null); // ... return true; } }