Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XEngine
XEngine MQService
提交
c4150a00
X
XEngine MQService
项目概览
XEngine
/
XEngine MQService
9 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
XEngine MQService
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c4150a00
编写于
8月 11, 2023
作者:
xengine-qyt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify:saved user info table for session module when client create
上级
ade752c6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
99 addition
and
24 deletion
+99
-24
XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.def
XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.def
+1
-0
XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp
...ssionModule/SessionModule_Client/SessionModule_Client.cpp
+57
-8
XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h
...SessionModule/SessionModule_Client/SessionModule_Client.h
+3
-2
XEngine_Source/MQCore_SessionModule/Session_Define.h
XEngine_Source/MQCore_SessionModule/Session_Define.h
+23
-4
XEngine_Source/MQCore_SessionModule/pch.cpp
XEngine_Source/MQCore_SessionModule/pch.cpp
+6
-2
XEngine_Source/MQCore_SessionModule/pch.h
XEngine_Source/MQCore_SessionModule/pch.h
+4
-4
XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp
XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp
+5
-4
未找到文件。
XEngine_Source/MQCore_SessionModule/MQCore_SessionModule.def
浏览文件 @
c4150a00
...
...
@@ -9,5 +9,6 @@ EXPORTS
SessionModule_Client_Delete
SessionModule_Client_GetUser
SessionModule_Client_GetAddr
SessionModule_Client_GetInfoByUser
SessionModule_Client_GetType
SessionModule_Client_Heart
\ No newline at end of file
XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.cpp
浏览文件 @
c4150a00
...
...
@@ -83,11 +83,11 @@ bool CSessionModule_Client::SessionModule_Client_Destory()
类型:常量字符指针
可空:N
意思:输入客户端地址
参数.二:
lpszUserName
参数.二:
pSt_UserInfo
In/Out:In
类型:
常量字符
指针
类型:
数据结构
指针
可空:N
意思:输入用户
名
意思:输入用户
信息
参数.三:nNetType
In/Out:In
类型:整数型
...
...
@@ -98,7 +98,7 @@ bool CSessionModule_Client::SessionModule_Client_Destory()
意思:是否成功
备注:
*********************************************************************/
bool
CSessionModule_Client
::
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
LPCXSTR
lpszUserName
,
int
nNetType
)
bool
CSessionModule_Client
::
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
,
int
nNetType
)
{
Session_IsErrorOccur
=
false
;
...
...
@@ -113,7 +113,7 @@ bool CSessionModule_Client::SessionModule_Client_Create(LPCXSTR lpszClientAddr,
st_SessionInfo
.
nNetType
=
nNetType
;
st_SessionInfo
.
nTimeStart
=
time
(
NULL
);
_tcsxcpy
(
st_SessionInfo
.
tszUserName
,
lpszUserName
)
;
st_SessionInfo
.
st_UserInfo
=
*
pSt_UserInfo
;
_tcsxcpy
(
st_SessionInfo
.
tszUserAddr
,
lpszClientAddr
);
st_Locker
.
lock
();
...
...
@@ -187,7 +187,7 @@ bool CSessionModule_Client::SessionModule_Client_GetUser(LPCXSTR lpszSessionStr,
}
if
(
NULL
!=
ptszUserName
)
{
_tcsxcpy
(
ptszUserName
,
stl_MapIterator
->
second
.
tszUserName
);
_tcsxcpy
(
ptszUserName
,
stl_MapIterator
->
second
.
st_UserInfo
.
tszUserName
);
}
st_Locker
.
unlock_shared
();
return
true
;
...
...
@@ -224,7 +224,7 @@ bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, X
st_Locker
.
lock_shared
();
for
(
auto
stl_MapIterator
=
stl_MapSession
.
begin
();
stl_MapIterator
!=
stl_MapSession
.
end
();
stl_MapIterator
++
)
{
if
(
0
==
_tcsxncmp
(
lpszUserName
,
stl_MapIterator
->
second
.
tszUserName
,
_tcsxlen
(
lpszUserName
)))
if
(
0
==
_tcsxncmp
(
lpszUserName
,
stl_MapIterator
->
second
.
st_UserInfo
.
tszUserName
,
_tcsxlen
(
lpszUserName
)))
{
bFound
=
true
;
if
(
NULL
!=
ptszUserAddr
)
...
...
@@ -245,6 +245,55 @@ bool CSessionModule_Client::SessionModule_Client_GetAddr(LPCXSTR lpszUserName, X
return
true
;
}
/********************************************************************
函数名称:SessionModule_Client_GetInfoByUser
函数功能:通过用户名获取用户信息
参数.一:lpszUserName
In/Out:In
类型:常量字符指针
可空:N
意思:输入用户名
参数.二:pSt_UserInfo
In/Out:Out
类型:数据结构指针
可空:N
意思:输出用户信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
bool
CSessionModule_Client
::
SessionModule_Client_GetInfoByUser
(
LPCXSTR
lpszUserName
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
)
{
Session_IsErrorOccur
=
false
;
if
(
NULL
==
lpszUserName
)
{
Session_IsErrorOccur
=
true
;
Session_dwErrorCode
=
ERROR_MQ_MODULE_SESSION_PARAMENT
;
return
false
;
}
bool
bFound
=
false
;
st_Locker
.
lock_shared
();
for
(
auto
stl_MapIterator
=
stl_MapSession
.
begin
();
stl_MapIterator
!=
stl_MapSession
.
end
();
stl_MapIterator
++
)
{
if
(
0
==
_tcsxncmp
(
lpszUserName
,
stl_MapIterator
->
second
.
st_UserInfo
.
tszUserName
,
_tcsxlen
(
lpszUserName
)))
{
bFound
=
true
;
*
pSt_UserInfo
=
stl_MapIterator
->
second
.
st_UserInfo
;
break
;
}
}
st_Locker
.
unlock_shared
();
if
(
!
bFound
)
{
Session_IsErrorOccur
=
true
;
Session_dwErrorCode
=
ERROR_MQ_MODULE_SESSION_NOTFOUND
;
return
false
;
}
return
true
;
}
/********************************************************************
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
...
...
@@ -349,7 +398,7 @@ XHTHREAD CALLBACK CSessionModule_Client::SessionModule_Client_Thread(XPVOID lPar
{
for
(
auto
stl_ListIterator
=
stl_ListClient
.
begin
();
stl_ListIterator
!=
stl_ListClient
.
end
();
stl_ListIterator
++
)
{
pClass_This
->
lpCall_Timeout
(
stl_ListIterator
->
tszUserAddr
,
stl_ListIterator
->
tszUserName
,
(
ENUM_MQCORE_SESSION_CLIENT_TYPE
)
stl_ListIterator
->
nNetType
,
pClass_This
->
m_lParam
);
pClass_This
->
lpCall_Timeout
(
stl_ListIterator
->
tszUserAddr
,
stl_ListIterator
->
st_UserInfo
.
tszUserName
,
(
ENUM_MQCORE_SESSION_CLIENT_TYPE
)
stl_ListIterator
->
nNetType
,
pClass_This
->
m_lParam
);
}
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
1
));
...
...
XEngine_Source/MQCore_SessionModule/SessionModule_Client/SessionModule_Client.h
浏览文件 @
c4150a00
...
...
@@ -12,8 +12,8 @@
*********************************************************************/
typedef
struct
{
XENGINE_PROTOCOL_USERINFO
st_UserInfo
;
//用户登录信息
XCHAR
tszUserAddr
[
128
];
//用户地址
XCHAR
tszUserName
[
128
];
//登录的用户名
time_t
nTimeStart
;
//时间
int
nNetType
;
//网络类型
}
XENGINE_SESSIONINFO
,
*
LPXENGINE_SESSIONINFO
;
...
...
@@ -26,10 +26,11 @@ public:
public:
bool
SessionModule_Client_Init
(
int
nSessionTime
,
CALLBACK_MESSAGEQUEUE_SESSIONMODULE_CLIENT_TIMEOUT
fpCall_Timeout
,
XPVOID
lParam
=
NULL
);
bool
SessionModule_Client_Destory
();
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
LPCXSTR
lpszUserName
,
int
nNetType
);
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
,
int
nNetType
);
bool
SessionModule_Client_Delete
(
LPCXSTR
lpszClientAddr
);
bool
SessionModule_Client_GetUser
(
LPCXSTR
lpszSessionStr
,
XCHAR
*
ptszUserName
=
NULL
);
bool
SessionModule_Client_GetAddr
(
LPCXSTR
lpszUserName
,
XCHAR
*
ptszUserAddr
=
NULL
);
bool
SessionModule_Client_GetInfoByUser
(
LPCXSTR
lpszUserName
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
);
bool
SessionModule_Client_GetType
(
LPCXSTR
lpszSessionStr
,
int
*
pInt_NetType
);
bool
SessionModule_Client_Heart
(
LPCXSTR
lpszClientAddr
);
protected:
...
...
XEngine_Source/MQCore_SessionModule/Session_Define.h
浏览文件 @
c4150a00
...
...
@@ -72,11 +72,11 @@ extern "C" bool SessionModule_Client_Destory();
类型:常量字符指针
可空:N
意思:输入客户端地址
参数.二:
lpszUserName
参数.二:
pSt_UserInfo
In/Out:In
类型:
常量字符
指针
类型:
数据结构
指针
可空:N
意思:输入用户
名
意思:输入用户
信息
参数.三:nNetType
In/Out:In
类型:整数型
...
...
@@ -87,7 +87,7 @@ extern "C" bool SessionModule_Client_Destory();
意思:是否成功
备注:
*********************************************************************/
extern
"C"
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
LPCXSTR
lpszUserName
,
int
nNetType
);
extern
"C"
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
,
int
nNetType
);
/********************************************************************
函数名称:SessionModule_Client_Delete
函数功能:删除一个用户
...
...
@@ -141,6 +141,25 @@ extern "C" bool SessionModule_Client_GetUser(LPCXSTR lpszSessionStr, XCHAR* ptsz
*********************************************************************/
extern
"C"
bool
SessionModule_Client_GetAddr
(
LPCXSTR
lpszUserName
,
XCHAR
*
ptszUserAddr
=
NULL
);
/********************************************************************
函数名称:SessionModule_Client_GetInfoByUser
函数功能:通过用户名获取用户信息
参数.一:lpszUserName
In/Out:In
类型:常量字符指针
可空:N
意思:输入用户名
参数.二:pSt_UserInfo
In/Out:Out
类型:数据结构指针
可空:N
意思:输出用户信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern
"C"
bool
SessionModule_Client_GetInfoByUser
(
LPCXSTR
lpszUserName
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
);
/********************************************************************
函数名称:SessionModule_Client_GetType
函数功能:通过客户端获得连接的网络类型
参数.一:lpszSessionStr
...
...
XEngine_Source/MQCore_SessionModule/pch.cpp
浏览文件 @
c4150a00
...
...
@@ -37,9 +37,9 @@ extern "C" bool SessionModule_Client_Destory()
{
return
m_SessionClient
.
SessionModule_Client_Destory
();
}
extern
"C"
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
LPCXSTR
lpszUserName
,
int
nNetType
)
extern
"C"
bool
SessionModule_Client_Create
(
LPCXSTR
lpszClientAddr
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
,
int
nNetType
)
{
return
m_SessionClient
.
SessionModule_Client_Create
(
lpszClientAddr
,
lpszUserName
,
nNetType
);
return
m_SessionClient
.
SessionModule_Client_Create
(
lpszClientAddr
,
pSt_UserInfo
,
nNetType
);
}
extern
"C"
bool
SessionModule_Client_Delete
(
LPCXSTR
lpszClientAddr
)
{
...
...
@@ -53,6 +53,10 @@ extern "C" bool SessionModule_Client_GetAddr(LPCXSTR lpszUserName, XCHAR * ptszU
{
return
m_SessionClient
.
SessionModule_Client_GetAddr
(
lpszUserName
,
ptszUserAddr
);
}
extern
"C"
bool
SessionModule_Client_GetInfoByUser
(
LPCXSTR
lpszUserName
,
XENGINE_PROTOCOL_USERINFO
*
pSt_UserInfo
)
{
return
m_SessionClient
.
SessionModule_Client_GetInfoByUser
(
lpszUserName
,
pSt_UserInfo
);
}
extern
"C"
bool
SessionModule_Client_GetType
(
LPCXSTR
lpszSessionStr
,
int
*
pInt_NetType
)
{
return
m_SessionClient
.
SessionModule_Client_GetType
(
lpszSessionStr
,
pInt_NetType
);
...
...
XEngine_Source/MQCore_SessionModule/pch.h
浏览文件 @
c4150a00
...
...
@@ -21,17 +21,17 @@
#include <shared_mutex>
#include <unordered_map>
#include <XEngine_Include/XEngine_CommHdr.h>
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_Types.h>
#include "../XQueue_ProtocolHdr.h"
#include "Session_Define.h"
#include "Session_Error.h"
using
namespace
std
;
#ifdef _UNICODE
typedef
std
::
wstring
tstring
;
#else
typedef
std
::
string
tstring
;
#endif
#include "../XQueue_ProtocolHdr.h"
#include "Session_Define.h"
#include "Session_Error.h"
/********************************************************************
// Created: 2021/07/02 10:16:47
// File Name: D:\XEngine_MQService\XEngine_Source\MQCore_SessionModule\pch.h
...
...
XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp
浏览文件 @
c4150a00
...
...
@@ -104,7 +104,6 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
XLOG_PRINT
(
xhLog
,
XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR
,
_X
(
"%s客户端:%s,请求登录到服务失败,因为用户已经登录了"
),
lpszClientType
,
lpszClientAddr
);
return
false
;
}
_tcsxcpy
(
st_UserInfo
.
tszUserName
,
st_ProtocolAuth
.
tszUserName
);
_tcsxcpy
(
st_UserInfo
.
tszUserPass
,
st_ProtocolAuth
.
tszUserPass
);
...
...
@@ -151,11 +150,11 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
//HTTP使用SESSION
BaseLib_OperatorHandle_Create
(
&
pSt_ProtocolHdr
->
xhToken
);
_xstprintf
(
tszSessionStr
,
_X
(
"%lld"
),
pSt_ProtocolHdr
->
xhToken
);
SessionModule_Client_Create
(
tszSessionStr
,
st_UserInfo
.
tszUserName
,
nNetType
);
SessionModule_Client_Create
(
tszSessionStr
,
&
st_UserInfo
,
nNetType
);
}
else
{
SessionModule_Client_Create
(
lpszClientAddr
,
st_UserInfo
.
tszUserName
,
nNetType
);
SessionModule_Client_Create
(
lpszClientAddr
,
&
st_UserInfo
,
nNetType
);
}
pSt_ProtocolHdr
->
wReserve
=
0
;
ProtocolModule_Packet_Common
(
nNetType
,
pSt_ProtocolHdr
,
NULL
,
tszSDBuffer
,
&
nSDLen
);
...
...
@@ -165,9 +164,11 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
else
if
(
XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_MQ_REQUSEROUT
==
pSt_ProtocolHdr
->
unOperatorCode
)
{
XENGINE_PROTOCOL_USERAUTH
st_ProtocolAuth
;
XENGINE_PROTOCOL_USERINFO
st_ProtocolInfo
;
memset
(
&
st_ProtocolAuth
,
'\0'
,
sizeof
(
XENGINE_PROTOCOL_USERAUTH
));
memset
(
&
st_ProtocolInfo
,
'\0'
,
sizeof
(
XENGINE_PROTOCOL_USERINFO
));
memcpy
(
&
st_ProtocolAuth
,
lpszMsgBuffer
,
sizeof
(
XENGINE_PROTOCOL_USERAUTH
));
XLOG_PRINT
(
xhLog
,
XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO
,
_X
(
"%s客户端:%s,用户登出成功,暂时没有作用,用户名:%s,密码:%s"
),
lpszClientType
,
lpszClientAddr
,
st_ProtocolAuth
.
tszUserName
,
st_ProtocolAuth
.
tszUserPass
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录