use of org.eclipse.milo.opcua.stack.core.types.structured.CloseSessionResponse in project milo by eclipse.
the class SessionManager method closeSession.
private CloseSessionResponse closeSession(ServiceRequest service) throws UaException {
CloseSessionRequest request = (CloseSessionRequest) service.getRequest();
long secureChannelId = service.getSecureChannelId();
NodeId authToken = service.getRequest().getRequestHeader().getAuthenticationToken();
Session session = activeSessions.get(authToken);
if (session != null) {
if (session.getSecureChannelId() != secureChannelId) {
throw new UaException(StatusCodes.Bad_SecureChannelIdInvalid);
} else {
activeSessions.remove(authToken);
session.close(request.getDeleteSubscriptions());
return new CloseSessionResponse(service.createResponseHeader());
}
} else {
session = createdSessions.get(authToken);
if (session == null) {
throw new UaException(StatusCodes.Bad_SessionIdInvalid);
} else if (session.getSecureChannelId() != secureChannelId) {
throw new UaException(StatusCodes.Bad_SecureChannelIdInvalid);
} else {
createdSessions.remove(authToken);
session.close(request.getDeleteSubscriptions());
return new CloseSessionResponse(service.createResponseHeader());
}
}
}
use of org.eclipse.milo.opcua.stack.core.types.structured.CloseSessionResponse in project milo by eclipse.
the class SessionManager method onCloseSession.
@Override
public void onCloseSession(ServiceRequest service) {
try {
CloseSessionResponse response = closeSession(service);
service.setResponse(response);
} catch (UaException e) {
service.setServiceFault(e);
}
}
Aggregations