CRecordSessionExpired
In nyssr.net, when a session token expires or the session is closed, a
broadcast is sent to all nodes.
You can register an observer for this message to receive it directly.
This message belongs to the session manager API.
It is part of the kernel.
{
"id": "274f6cd9-f1fe-4973-9f0e-fd26db19d276",
"name": "SESSION_EXPIRED",
"description": "A session has been expired due to inactivity.",
"isNanoService": "true",
"namespaces": "SYSTEM",
"slots": [
]
}
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(CRecordSessionExpired.class,
this,
false);
// or use the Nanoservice registry
mDependencies.getSystemNanoserviceRegistry()
.addObserver(CRecordSessionExpired.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(CRecordSessionExpired.ID,
this::asyncSessionExpired);
private boolean asyncSessionExpired(@NotNull final CEnvelope aEnvelope,
@NotNull final CRecord aRecord)
{
if (aEnvelope.isAnswer())
{
return false;
}
else
{
final byte[] sessionToken = aEnvelope.getSessionToken();
// ...
return true;
}
}
Related Pages
CRecordSessionLogout
CRecordSessionLogout message: Used to close or quit an existing user session in nyssr.net.
CRecordSessionManagementAvailable
CRecordSessionManagementAvailable message: A broadcast sent to all nyssr.net nodes announcing whether the session management service is available and its address.
CRecordSessionValidate
CRecordSessionValidate message: Used to check the validity of a session token and, upon success, retrieves the corresponding user ID and assigned rights.
CRecordSessionLogin
CRecordSessionLogin message: Used for user login in nyssr.net, requiring the user ID and the Base64-encoded SHA384 hash of the password for authentication.
CRecordSessionCreateRight
CRecordSessionCreateRight message: Used to create and store a new permission/right in the nyssr.net database, which can then be assigned to users or roles.
Technical Overview of nyssr.net
The nyssr.net technical overview details its Java node mesh, micro-kernel, and asynchronous message protocol. It covers local, micro, and nano services, dynamic routing, zero-config load balancing, an