ua_session_manager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include "../../deps/queue.h"
  17. #include "ua_server.h"
  18. #include "ua_util.h"
  19. #include "ua_session.h"
  20. typedef struct session_list_entry {
  21. LIST_ENTRY(session_list_entry) pointers;
  22. UA_Session session;
  23. } session_list_entry;
  24. typedef struct UA_SessionManager {
  25. LIST_HEAD(session_list, session_list_entry) sessions; // doubly-linked list of sessions
  26. UA_UInt32 currentSessionCount;
  27. UA_Server *server;
  28. } UA_SessionManager;
  29. UA_StatusCode
  30. UA_SessionManager_init(UA_SessionManager *sm, UA_Server *server);
  31. /* Deletes all sessions */
  32. void UA_SessionManager_deleteMembers(UA_SessionManager *sm);
  33. /* Deletes all sessions that have timed out. Deletion is implemented via a
  34. * delayed callback. So all currently scheduled jobs with a pointer to the
  35. * session can complete. */
  36. void UA_SessionManager_cleanupTimedOut(UA_SessionManager *sm,
  37. UA_DateTime nowMonotonic);
  38. UA_StatusCode
  39. UA_SessionManager_createSession(UA_SessionManager *sm, UA_SecureChannel *channel,
  40. const UA_CreateSessionRequest *request, UA_Session **session);
  41. UA_StatusCode
  42. UA_SessionManager_removeSession(UA_SessionManager *sm, const UA_NodeId *token);
  43. UA_Session *
  44. UA_SessionManager_getSessionByToken(UA_SessionManager *sm, const UA_NodeId *token);
  45. UA_Session *
  46. UA_SessionManager_getSessionById(UA_SessionManager *sm, const UA_NodeId *sessionId);
  47. #ifdef __cplusplus
  48. } // extern "C"
  49. #endif
  50. #endif /* UA_SESSION_MANAGER_H_ */