mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-14 03:55:58 +08:00
整理命名空间 (#1409)
* feat: remove using namespace mediakit in header files. (cherry picked from commit d44aeb339a8a0e1f0455be82b21fe4b1b536299f) * feat: remove using namespace mediakit in FFmpegSource.h * feat: remove using namespace mediakit in RtpExt.h * feat: remove using namespace mediakit in header files. * feat: remove using namespace std in header files. * feat: remove using namespace std in header files when zltoolkit remove std in header * 补充命名空间 * 整理命名空间 * 整理命名空间2 * 修复macos ci * 修复编译问题 * 修复编译问题2 * 修复编译问题3 Co-authored-by: Johnny <hellojinqiang@gmail.com> Co-authored-by: Xiaofeng Wang <wasphin@gmail.com>
This commit is contained in:
@@ -19,10 +19,6 @@
|
||||
#include "Network/Socket.h"
|
||||
#include "Common/Parser.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
#define COOKIE_DEFAULT_LIFE (7 * 24 * 60 * 60)
|
||||
|
||||
namespace mediakit {
|
||||
@@ -32,7 +28,7 @@ class HttpCookieManager;
|
||||
/**
|
||||
* cookie对象,用于保存cookie的一些相关属性
|
||||
*/
|
||||
class HttpServerCookie : public AnyStorage , public noncopyable{
|
||||
class HttpServerCookie : public toolkit::AnyStorage , public toolkit::noncopyable{
|
||||
public:
|
||||
typedef std::shared_ptr<HttpServerCookie> Ptr;
|
||||
/**
|
||||
@@ -45,9 +41,9 @@ public:
|
||||
*/
|
||||
|
||||
HttpServerCookie(const std::shared_ptr<HttpCookieManager> &manager,
|
||||
const string &cookie_name,
|
||||
const string &uid,
|
||||
const string &cookie,
|
||||
const std::string &cookie_name,
|
||||
const std::string &uid,
|
||||
const std::string &cookie,
|
||||
uint64_t max_elapsed);
|
||||
~HttpServerCookie() ;
|
||||
|
||||
@@ -55,7 +51,7 @@ public:
|
||||
* 获取uid
|
||||
* @return uid
|
||||
*/
|
||||
const string &getUid() const;
|
||||
const std::string &getUid() const;
|
||||
|
||||
/**
|
||||
* 获取http中Set-Cookie字段的值
|
||||
@@ -63,19 +59,19 @@ public:
|
||||
* @param path http访问路径
|
||||
* @return 例如 MY_SESSION=XXXXXX;expires=Wed, Jun 12 2019 06:30:48 GMT;path=/index/files/
|
||||
*/
|
||||
string getCookie(const string &path) const;
|
||||
std::string getCookie(const std::string &path) const;
|
||||
|
||||
/**
|
||||
* 获取cookie随机字符串
|
||||
* @return cookie随机字符串
|
||||
*/
|
||||
const string& getCookie() const;
|
||||
const std::string& getCookie() const;
|
||||
|
||||
/**
|
||||
* 获取该cookie名
|
||||
* @return
|
||||
*/
|
||||
const string& getCookieName() const;
|
||||
const std::string& getCookieName() const;
|
||||
|
||||
/**
|
||||
* 更新该cookie的过期时间,可以让此cookie不失效
|
||||
@@ -92,16 +88,16 @@ public:
|
||||
* 获取区域锁
|
||||
* @return
|
||||
*/
|
||||
std::shared_ptr<lock_guard<recursive_mutex> > getLock();
|
||||
std::shared_ptr<std::lock_guard<std::recursive_mutex> > getLock();
|
||||
private:
|
||||
string cookieExpireTime() const ;
|
||||
std::string cookieExpireTime() const ;
|
||||
private:
|
||||
string _uid;
|
||||
string _cookie_name;
|
||||
string _cookie_uuid;
|
||||
std::string _uid;
|
||||
std::string _cookie_name;
|
||||
std::string _cookie_uuid;
|
||||
uint64_t _max_elapsed;
|
||||
Ticker _ticker;
|
||||
recursive_mutex _mtx;
|
||||
toolkit::Ticker _ticker;
|
||||
std::recursive_mutex _mtx;
|
||||
std::weak_ptr<HttpCookieManager> _manager;
|
||||
};
|
||||
|
||||
@@ -117,18 +113,18 @@ public:
|
||||
* 获取不碰撞的随机字符串
|
||||
* @return 随机字符串
|
||||
*/
|
||||
string obtain();
|
||||
std::string obtain();
|
||||
|
||||
/**
|
||||
* 释放随机字符串
|
||||
* @param str 随机字符串
|
||||
*/
|
||||
void release(const string &str);
|
||||
void release(const std::string &str);
|
||||
private:
|
||||
string obtain_l();
|
||||
std::string obtain_l();
|
||||
private:
|
||||
//碰撞库
|
||||
unordered_set<string> _obtained;
|
||||
std::unordered_set<std::string> _obtained;
|
||||
//增长index,防止碰撞用
|
||||
int _index = 0;
|
||||
};
|
||||
@@ -156,7 +152,7 @@ public:
|
||||
* @param max_elapsed 该cookie过期时间,单位秒
|
||||
* @return cookie对象
|
||||
*/
|
||||
HttpServerCookie::Ptr addCookie(const string &cookie_name,const string &uid, uint64_t max_elapsed = COOKIE_DEFAULT_LIFE,int max_client = 1);
|
||||
HttpServerCookie::Ptr addCookie(const std::string &cookie_name,const std::string &uid, uint64_t max_elapsed = COOKIE_DEFAULT_LIFE,int max_client = 1);
|
||||
|
||||
/**
|
||||
* 根据cookie随机字符串查找cookie对象
|
||||
@@ -164,7 +160,7 @@ public:
|
||||
* @param cookie cookie随机字符串
|
||||
* @return cookie对象,可以为nullptr
|
||||
*/
|
||||
HttpServerCookie::Ptr getCookie(const string &cookie_name,const string &cookie);
|
||||
HttpServerCookie::Ptr getCookie(const std::string &cookie_name,const std::string &cookie);
|
||||
|
||||
/**
|
||||
* 从http头中获取cookie对象
|
||||
@@ -172,7 +168,7 @@ public:
|
||||
* @param http_header http头
|
||||
* @return cookie对象
|
||||
*/
|
||||
HttpServerCookie::Ptr getCookie(const string &cookie_name,const StrCaseMap &http_header);
|
||||
HttpServerCookie::Ptr getCookie(const std::string &cookie_name,const StrCaseMap &http_header);
|
||||
|
||||
/**
|
||||
* 根据uid获取cookie
|
||||
@@ -180,7 +176,7 @@ public:
|
||||
* @param uid 用户id
|
||||
* @return cookie对象
|
||||
*/
|
||||
HttpServerCookie::Ptr getCookieByUid(const string &cookie_name,const string &uid);
|
||||
HttpServerCookie::Ptr getCookieByUid(const std::string &cookie_name,const std::string &uid);
|
||||
|
||||
/**
|
||||
* 删除cookie,用户登出时使用
|
||||
@@ -197,7 +193,7 @@ private:
|
||||
* @param uid 用户id
|
||||
* @param cookie cookie随机字符串
|
||||
*/
|
||||
void onAddCookie(const string &cookie_name,const string &uid,const string &cookie);
|
||||
void onAddCookie(const std::string &cookie_name,const std::string &uid,const std::string &cookie);
|
||||
|
||||
/**
|
||||
* 析构cookie对象时触发
|
||||
@@ -205,7 +201,7 @@ private:
|
||||
* @param uid 用户id
|
||||
* @param cookie cookie随机字符串
|
||||
*/
|
||||
void onDelCookie(const string &cookie_name,const string &uid,const string &cookie);
|
||||
void onDelCookie(const std::string &cookie_name,const std::string &uid,const std::string &cookie);
|
||||
|
||||
/**
|
||||
* 获取某用户名下最先登录时的cookie,目的是实现某用户下最多登录若干个设备
|
||||
@@ -214,7 +210,7 @@ private:
|
||||
* @param max_client 最多登录的设备个数
|
||||
* @return 最早的cookie随机字符串
|
||||
*/
|
||||
string getOldestCookie(const string &cookie_name,const string &uid, int max_client = 1);
|
||||
std::string getOldestCookie(const std::string &cookie_name,const std::string &uid, int max_client = 1);
|
||||
|
||||
/**
|
||||
* 删除cookie
|
||||
@@ -222,12 +218,12 @@ private:
|
||||
* @param cookie cookie随机字符串
|
||||
* @return 成功true
|
||||
*/
|
||||
bool delCookie(const string &cookie_name,const string &cookie);
|
||||
bool delCookie(const std::string &cookie_name,const std::string &cookie);
|
||||
private:
|
||||
unordered_map<string/*cookie_name*/,unordered_map<string/*cookie*/,HttpServerCookie::Ptr/*cookie_data*/> >_map_cookie;
|
||||
unordered_map<string/*cookie_name*/,unordered_map<string/*uid*/,map<uint64_t/*cookie time stamp*/,string/*cookie*/> > >_map_uid_to_cookie;
|
||||
recursive_mutex _mtx_cookie;
|
||||
Timer::Ptr _timer;
|
||||
std::unordered_map<std::string/*cookie_name*/,std::unordered_map<std::string/*cookie*/,HttpServerCookie::Ptr/*cookie_data*/> >_map_cookie;
|
||||
std::unordered_map<std::string/*cookie_name*/,std::unordered_map<std::string/*uid*/,std::map<uint64_t/*cookie time stamp*/,std::string/*cookie*/> > >_map_uid_to_cookie;
|
||||
std::recursive_mutex _mtx_cookie;
|
||||
toolkit::Timer::Ptr _timer;
|
||||
RandStrGeneator _geneator;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user