CRecordSessionLogout
Quit the session.
This message belongs to the session manager API.
It is part of the kernel.
{ "id": "7f736870-b41b-48ea-9220-6f104cae17d3", "name": "SESSION_LOGOUT ", "description": "Close the session.", "slots": [ ] }
Usage
Sending the request
You need the microservice ID of the session manager:
public static final IIdSESSION_MICROSERVICE_ID = CIdFactory.fromObject("ccf168c1-f18b-4229-85f9-24461a19ee6a");
To close the session, we need the token we received when we logged in.
private void closeSession(final byte[] aToken) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID ); env.setSessionToken(aToken); final CRecord record =CRecordSessionLogout .create(); sendRequest(env, record); }
Dealing with the response
To catch the response of the request, we need a message handler. We add it in the constructor of the message handler registry.
// constructor: addMessageHandler(CRecordSessionLogout .ID, this::asyncSessionLogout );
private booleanasyncSessionLogout (@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { // ... } return true; } return false; }