session.cpp 1.11 KB
#include "stdafx.h"

#include "etradeclient/utility/session.h"

#include "include/wrapper/cef_helpers.h"

Session::Session() : m_expried(true) /*The initial state should be 'expired'.*/
{}

Session& Session::Instance()
{
	static Session session_manager;
	
#if 0
	session_manager.m_user_name = L"relogin_dlg_test";
#endif

	return session_manager;
}

void Session::OnExpired()
{
	std::lock_guard<std::mutex> lg(m_mtx); 
	//CEF_REQUIRE_IO_THREAD();

	m_cookies.clear();
	m_expried = true;
}

void Session::OnValid()
{
	std::lock_guard<std::mutex> lg(m_mtx);
	m_expried = false;
}

bool Session::IsExpired()
{
	std::lock_guard<std::mutex> lg(m_mtx);
	return m_expried;
}

void Session::SetCookies(const CookiesT& cookies)
{
	m_cookies = cookies;
}

const Session::CookiesT& Session::Cookies() const
{
	return m_cookies;
}

void Session::SetUserName(const std::wstring& user_name)
{
	m_user_name = user_name;
}

const std::wstring& Session::UserName() const
{
	return m_user_name;
}

void Session::SetMerName(const std::wstring& sMerName)
{
	m_mer_name = sMerName;
}

const std::wstring& Session::GetMerName() const
{
	return m_mer_name;
}