CRecordSessionLogout
Quit the session.
This message belongs to the session manager API.
{ "id": "7f736870-b41b-48ea-9220-6f104cae17d3", "name": "SESSION_LOGOUT", "description": "Close the session.", "slots": [ { "key": "token", "name": "TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." } ] }
Example of use of the class CRecordSessionLogout (after generating)
You need the microservice ID of the session manager:
public static final IId SESSION_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(@NotNull final UUID aToken) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordSessionLogout.create(); CRecordSessionLogin.setToken(record, aToken); sendRequest(env, record); }
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 boolean asyncSessionLogout(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { final UUID token = CRecordSessionLogout.getToken(aRecord, null); // ... } return true; } return false; }