mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
添加用户追踪事件
This commit is contained in:
parent
080f2af4b4
commit
20e62b103a
@ -58,6 +58,7 @@ const string kBroadcastMediaChanged = "kBroadcastMediaChanged";
|
||||
const string kBroadcastRecordMP4 = "kBroadcastRecordMP4";
|
||||
const string kBroadcastHttpRequest = "kBroadcastHttpRequest";
|
||||
const string kBroadcastHttpAccess = "kBroadcastHttpAccess";
|
||||
const string kBroadcastTrackHttpClient = "kBroadcastTrackHttpClient";
|
||||
const string kBroadcastOnGetRtspRealm = "kBroadcastOnGetRtspRealm";
|
||||
const string kBroadcastOnRtspAuth = "kBroadcastOnRtspAuth";
|
||||
const string kBroadcastMediaPlayed = "kBroadcastMediaPlayed";
|
||||
|
@ -79,10 +79,16 @@ extern const string kBroadcastRecordMP4;
|
||||
extern const string kBroadcastHttpRequest;
|
||||
#define BroadcastHttpRequestArgs const Parser &parser,const HttpSession::HttpResponseInvoker &invoker,bool &consumed,TcpSession &sender
|
||||
|
||||
//收到http 访问文件或目录的广播
|
||||
//收到http 访问文件或目录的广播,通过该事件控制访问http目录的权限
|
||||
extern const string kBroadcastHttpAccess;
|
||||
#define BroadcastHttpAccessArgs const Parser &parser,const MediaInfo &args,const string &path,const bool &is_dir,const HttpSession::HttpAccessPathInvoker &invoker,TcpSession &sender
|
||||
|
||||
//追踪用户事件,如果http客户端不支持cookie,ip端口又一直变,那么可以根据url参数来追踪用户,
|
||||
//从而减少kBroadcastHttpAccess事件触发的次数。
|
||||
extern const string kBroadcastTrackHttpClient;
|
||||
#define BroadcastTrackHttpClientArgs const Parser &parser,string &uid,TcpSession &sender
|
||||
|
||||
|
||||
//该流是否需要认证?是的话调用invoker并传入realm,否则传入空的realm.如果该事件不监听则不认证
|
||||
extern const string kBroadcastOnGetRtspRealm;
|
||||
#define BroadcastOnGetRtspRealmArgs const MediaInfo &args,const RtspSession::onGetRealm &invoker,TcpSession &sender
|
||||
|
@ -325,10 +325,18 @@ inline string HttpSession::getClientUid(){
|
||||
//该ip端口只能有一个cookie,不能重复获取cookie,
|
||||
//目的是为了防止我们让客户端设置cookie,但是客户端不支持cookie导致一直重复生成cookie
|
||||
//判断是否为同一个用户还可以根据url相关字段,但是这个跟具体业务逻辑相关,在这里不便实现
|
||||
//如果一个http客户端不支持cookie并且一直变换端口号,那么会导致服务器无法追踪该用户,从而导致一直触发事件并且一直生成cookie
|
||||
return StrPrinter << get_peer_ip() << ":" << get_peer_port();
|
||||
//如果一个http客户端不支持cookie并且一直变换端口号,那么可能会导致服务器无法追踪该用户,从而导致一直触发事件并且一直生成cookie
|
||||
string uid = StrPrinter << get_peer_ip() << ":" << get_peer_port();
|
||||
//所以我们通过kBroadcastTrackHttpClient事件来让业务逻辑自行决定根据url参数追踪用户
|
||||
NoticeCenter::Instance().emitEventNoCopy(Broadcast::kBroadcastTrackHttpClient,_parser,uid,*this);
|
||||
return uid;
|
||||
}
|
||||
inline void HttpSession::canAccessPath(const string &path_in,bool is_dir,const function<void(bool canAccess,const CookieData::Ptr &cookie)> &callback_in){
|
||||
if(NoticeCenter::Instance().listenerSize(Broadcast::kBroadcastHttpAccess) == 0){
|
||||
//该事件无人监听,那么就不做cookie查找这样费时的操作
|
||||
callback_in(true, nullptr);
|
||||
return;
|
||||
}
|
||||
auto path = path_in;
|
||||
replace(const_cast<string &>(path),"//","/");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user