2019-03-26 22:04:53 +00:00
|
|
|
#include "webfuse/adapter/impl/session_manager.h"
|
2019-04-01 20:15:12 +00:00
|
|
|
#include "webfuse/core/util.h"
|
2019-03-26 22:04:53 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
void wf_impl_session_manager_init(
|
|
|
|
struct wf_impl_session_manager * manager)
|
|
|
|
{
|
2019-04-01 20:15:12 +00:00
|
|
|
wf_impl_session_init(&manager->session, NULL, NULL, NULL, NULL);
|
2019-03-26 22:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wf_impl_session_manager_cleanup(
|
|
|
|
struct wf_impl_session_manager * manager)
|
|
|
|
{
|
|
|
|
wf_impl_session_cleanup(&manager->session);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wf_impl_session * wf_impl_session_manager_add(
|
|
|
|
struct wf_impl_session_manager * manager,
|
|
|
|
struct lws * wsi,
|
|
|
|
struct wf_impl_authenticators * authenticators,
|
2019-04-01 20:15:12 +00:00
|
|
|
struct wf_impl_timeout_manager * timeout_manager,
|
|
|
|
struct wf_impl_jsonrpc_server * server)
|
2019-03-26 22:04:53 +00:00
|
|
|
{
|
|
|
|
struct wf_impl_session * session = NULL;
|
|
|
|
if (NULL == manager->session.wsi)
|
|
|
|
{
|
|
|
|
session = &manager->session;
|
2019-04-01 20:15:12 +00:00
|
|
|
wf_impl_session_init(&manager->session, wsi, authenticators, timeout_manager, server);
|
2019-03-26 22:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wf_impl_session * wf_impl_session_manager_get(
|
|
|
|
struct wf_impl_session_manager * manager,
|
|
|
|
struct lws * wsi)
|
|
|
|
{
|
|
|
|
struct wf_impl_session * session = NULL;
|
|
|
|
if (wsi == manager->session.wsi)
|
|
|
|
{
|
|
|
|
session = &manager->session;
|
|
|
|
}
|
|
|
|
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
|
2019-04-01 20:15:12 +00:00
|
|
|
struct wf_impl_session * wf_impl_session_manager_get_by_inode(
|
|
|
|
struct wf_impl_session_manager * manager,
|
|
|
|
fuse_ino_t WF_UNUSED_PARAM(inode))
|
|
|
|
{
|
|
|
|
// ToDo: use inode to determine session manager
|
|
|
|
|
|
|
|
struct wf_impl_session * session = NULL;
|
|
|
|
if (NULL != manager->session.wsi)
|
|
|
|
{
|
|
|
|
session = &manager->session;
|
|
|
|
}
|
|
|
|
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-26 22:04:53 +00:00
|
|
|
void wf_impl_session_manager_remove(
|
|
|
|
struct wf_impl_session_manager * manager,
|
|
|
|
struct lws * wsi)
|
|
|
|
{
|
|
|
|
if (wsi == manager->session.wsi)
|
|
|
|
{
|
|
|
|
wf_impl_session_cleanup(&manager->session);
|
|
|
|
manager->session.wsi = NULL;
|
|
|
|
}
|
|
|
|
}
|