ua_session_manager.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2014, 2017 (c) Florian Palm
  7. * Copyright 2015 (c) Sten Grüner
  8. * Copyright 2015 (c) Oleksiy Vasylyev
  9. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  10. */
  11. #ifndef UA_SESSION_MANAGER_H_
  12. #define UA_SESSION_MANAGER_H_
  13. #include "ua_server.h"
  14. #include "ua_util_internal.h"
  15. #include "ua_session.h"
  16. #include "../../deps/queue.h"
  17. _UA_BEGIN_DECLS
  18. typedef struct session_list_entry {
  19. LIST_ENTRY(session_list_entry) pointers;
  20. UA_Session session;
  21. } session_list_entry;
  22. typedef struct UA_SessionManager {
  23. LIST_HEAD(session_list, session_list_entry) sessions; // doubly-linked list of sessions
  24. UA_UInt32 currentSessionCount;
  25. UA_Server *server;
  26. } UA_SessionManager;
  27. UA_StatusCode
  28. UA_SessionManager_init(UA_SessionManager *sm, UA_Server *server);
  29. /* Deletes all sessions */
  30. void UA_SessionManager_deleteMembers(UA_SessionManager *sm);
  31. /* Deletes all sessions that have timed out. Deletion is implemented via a
  32. * delayed callback. So all currently scheduled jobs with a pointer to the
  33. * session can complete. */
  34. void UA_SessionManager_cleanupTimedOut(UA_SessionManager *sm,
  35. UA_DateTime nowMonotonic);
  36. UA_StatusCode
  37. UA_SessionManager_createSession(UA_SessionManager *sm, UA_SecureChannel *channel,
  38. const UA_CreateSessionRequest *request, UA_Session **session);
  39. UA_StatusCode
  40. UA_SessionManager_removeSession(UA_SessionManager *sm, const UA_NodeId *token);
  41. UA_Session *
  42. UA_SessionManager_getSessionByToken(UA_SessionManager *sm, const UA_NodeId *token);
  43. UA_Session *
  44. UA_SessionManager_getSessionById(UA_SessionManager *sm, const UA_NodeId *sessionId);
  45. _UA_END_DECLS
  46. #endif /* UA_SESSION_MANAGER_H_ */