Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
d52f4ed0
Commit
d52f4ed0
authored
Oct 08, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除调试日志
parent
0d8525e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
28 deletions
+1
-28
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+0
-25
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+1
-3
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
d52f4ed0
...
@@ -98,31 +98,23 @@ public class NormalChatAction {
...
@@ -98,31 +98,23 @@ public class NormalChatAction {
// if (log.isDebugEnabled()) {
// if (log.isDebugEnabled()) {
// log.debug("接收到参数,reqId: {},\n data: {}, ", reqId, data);
// log.debug("接收到参数,reqId: {},\n data: {}, ", reqId, data);
// }
// }
Long
conTime
=
System
.
currentTimeMillis
();
ImConversationQueryVo
conversation
=
ehcacheService
.
getEhCacheConversation
(
data
.
getToConversation
());
ImConversationQueryVo
conversation
=
ehcacheService
.
getEhCacheConversation
(
data
.
getToConversation
());
log
.
info
(
"获取会话缓存耗时 {}"
,
System
.
currentTimeMillis
()
-
conTime
);
if
(
conversation
==
null
)
{
if
(
conversation
==
null
)
{
log
.
warn
(
"会reqId: {} ,会话id: {}db中不存在"
,
reqId
,
data
.
getToConversation
());
log
.
warn
(
"会reqId: {} ,会话id: {}db中不存在"
,
reqId
,
data
.
getToConversation
());
return
;
return
;
}
}
// 查询发送者client
// 查询发送者client
Long
clientTime
=
System
.
currentTimeMillis
();
ImClient
imClientSender
=
ehcacheService
.
getEhCacheClient
(
request
.
getSenderClientId
());
ImClient
imClientSender
=
ehcacheService
.
getEhCacheClient
(
request
.
getSenderClientId
());
log
.
info
(
"获取用户缓存耗时 {}"
,
System
.
currentTimeMillis
()
-
clientTime
);
if
(
imClientSender
==
null
)
{
if
(
imClientSender
==
null
)
{
log
.
warn
(
"根据senderClientId: {} 查找不到 imClientSender!"
,
request
.
getSenderClientId
());
log
.
warn
(
"根据senderClientId: {} 查找不到 imClientSender!"
,
request
.
getSenderClientId
());
return
;
return
;
}
}
// 查询imApplication
// 查询imApplication
Long
appTime
=
System
.
currentTimeMillis
();
ImApplication
imApplication
=
imApplicationService
.
getCacheById
(
imClientSender
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
getCacheById
(
imClientSender
.
getFkAppid
());
log
.
info
(
"获取app缓存耗时 {}"
,
System
.
currentTimeMillis
()
-
appTime
);
// 给所有人(在线+离线)遍历发送
// 给所有人(在线+离线)遍历发送
// 先查询该会话所有成员
// 先查询该会话所有成员
Long
memberTime
=
System
.
currentTimeMillis
();
List
<
ImConversationMembers
>
membersList
=
ehcacheService
.
getEhCacheMember
(
"member"
+
conversation
.
getId
(),
conversation
.
getId
());
List
<
ImConversationMembers
>
membersList
=
ehcacheService
.
getEhCacheMember
(
"member"
+
conversation
.
getId
(),
conversation
.
getId
());
log
.
info
(
"获取成员缓存耗时 {}"
,
System
.
currentTimeMillis
()
-
memberTime
);
if
(
membersList
.
isEmpty
())
{
if
(
membersList
.
isEmpty
())
{
log
.
info
(
"查询会话所有成员返回空,会话ID: {}"
,
data
.
getToConversation
());
log
.
info
(
"查询会话所有成员返回空,会话ID: {}"
,
data
.
getToConversation
());
WsResponse
<
HashMap
<
String
,
Long
>>
responseModel
=
new
WsResponse
<>();
WsResponse
<
HashMap
<
String
,
Long
>>
responseModel
=
new
WsResponse
<>();
...
@@ -134,11 +126,8 @@ public class NormalChatAction {
...
@@ -134,11 +126,8 @@ public class NormalChatAction {
channelSender
.
sendMsgLocal
((
NioSocketChannel
)
request
.
getSenderChannel
(),
responseModel
);
channelSender
.
sendMsgLocal
((
NioSocketChannel
)
request
.
getSenderChannel
(),
responseModel
);
return
;
return
;
}
}
Long
memberMapTime
=
System
.
currentTimeMillis
();
Map
<
Long
,
ImConversationMembers
>
memberMap
=
membersList
.
stream
().
collect
(
Collectors
.
toMap
(
ImConversationMembers:
:
getFkClientId
,
member
->
member
));
Map
<
Long
,
ImConversationMembers
>
memberMap
=
membersList
.
stream
().
collect
(
Collectors
.
toMap
(
ImConversationMembers:
:
getFkClientId
,
member
->
member
));
log
.
info
(
"获取成员map耗时 {}"
,
System
.
currentTimeMillis
()
-
memberMapTime
);
Long
checkTime
=
System
.
currentTimeMillis
();
// 判断为单聊
// 判断为单聊
if
(
ChatTypeEnum
.
SINGLE
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
if
(
ChatTypeEnum
.
SINGLE
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
// 判断是否被拉黑逻辑
// 判断是否被拉黑逻辑
...
@@ -161,22 +150,14 @@ public class NormalChatAction {
...
@@ -161,22 +150,14 @@ public class NormalChatAction {
return
;
return
;
}
}
}
}
log
.
info
(
"消息校验耗时 {}"
,
System
.
currentTimeMillis
()
-
checkTime
);
Long
neirongTime
=
System
.
currentTimeMillis
();
// 消息内容校验
// 消息内容校验
if
(!
checkMsg
(
imClientSender
,
conversation
,
reqId
,
data
,
request
.
getSenderChannel
(),
memberMap
))
{
if
(!
checkMsg
(
imClientSender
,
conversation
,
reqId
,
data
,
request
.
getSenderChannel
(),
memberMap
))
{
return
;
return
;
}
}
log
.
info
(
"消息校验耗时 {}"
,
System
.
currentTimeMillis
()
-
neirongTime
);
Long
messageTime
=
System
.
currentTimeMillis
();
ImMessageOnlineSend
imMessageOnlineSend
=
assembleImMessageOnlineSend
(
data
,
imClientSender
,
imApplication
.
getId
());
ImMessageOnlineSend
imMessageOnlineSend
=
assembleImMessageOnlineSend
(
data
,
imClientSender
,
imApplication
.
getId
());
log
.
info
(
"消息校验耗时 {}"
,
System
.
currentTimeMillis
()
-
messageTime
);
// 入库 保存收件箱
// 入库 保存收件箱
Long
inboxTime
=
System
.
currentTimeMillis
();
batchSaveInbox
(
imApplication
,
imClientSender
,
conversation
,
imMessageOnlineSend
.
getMsgId
(),
membersList
);
batchSaveInbox
(
imApplication
,
imClientSender
,
conversation
,
imMessageOnlineSend
.
getMsgId
(),
membersList
);
log
.
info
(
"收件箱耗时 {}"
,
System
.
currentTimeMillis
()
-
inboxTime
);
// 入库成功后 判断是否是临时会话 如果是,双方会话display状态是否是1(显示),如果不是,需要修改为是
// 入库成功后 判断是否是临时会话 如果是,双方会话display状态是否是1(显示),如果不是,需要修改为是
if
(
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
if
(
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
// 木有只有私聊一种临时会话类型
// 木有只有私聊一种临时会话类型
...
@@ -191,7 +172,6 @@ public class NormalChatAction {
...
@@ -191,7 +172,6 @@ public class NormalChatAction {
imConversationMembersService
.
updateBatchById
(
tempMemberToUpdate
);
imConversationMembersService
.
updateBatchById
(
tempMemberToUpdate
);
}
}
}
}
Long
pushTime
=
System
.
currentTimeMillis
();
final
Boolean
isPush
=
ehcacheService
.
getIsPush
(
"push"
+
conversation
.
getId
());
final
Boolean
isPush
=
ehcacheService
.
getIsPush
(
"push"
+
conversation
.
getId
());
// 多线程处理消息下发
// 多线程处理消息下发
for
(
ImConversationMembers
member
:
membersList
)
{
for
(
ImConversationMembers
member
:
membersList
)
{
...
@@ -203,19 +183,14 @@ public class NormalChatAction {
...
@@ -203,19 +183,14 @@ public class NormalChatAction {
this
.
sendMsgToMember
(
imApplication
,
member
,
imMessageOnlineSend
,
data
.
getPush
(),
isPush
);
this
.
sendMsgToMember
(
imApplication
,
member
,
imMessageOnlineSend
,
data
.
getPush
(),
isPush
);
});
});
}
}
log
.
info
(
"push耗时 {}"
,
System
.
currentTimeMillis
()
-
pushTime
);
// 响应发送方消息id等信息
// 响应发送方消息id等信息
Long
resTime
=
System
.
currentTimeMillis
();
response
(
reqId
,
imMessageOnlineSend
.
getMsgId
(),
request
.
getSenderChannel
());
response
(
reqId
,
imMessageOnlineSend
.
getMsgId
(),
request
.
getSenderChannel
());
log
.
info
(
"响应耗时 {}"
,
System
.
currentTimeMillis
()
-
resTime
);
}
}
private
void
sendMsgToMember
(
ImApplication
imApplication
,
ImConversationMembers
member
,
ImMessageOnlineSend
imMessageOnlineSend
,
PushVO
push
,
Boolean
isPush
)
{
private
void
sendMsgToMember
(
ImApplication
imApplication
,
ImConversationMembers
member
,
ImMessageOnlineSend
imMessageOnlineSend
,
PushVO
push
,
Boolean
isPush
)
{
// 在线用户直接发消息
// 在线用户直接发消息
Long
onlienTime
=
System
.
currentTimeMillis
();
Boolean
sendSuccess
=
sendMsgForOnline
(
member
.
getFkClientId
(),
imMessageOnlineSend
);
Boolean
sendSuccess
=
sendMsgForOnline
(
member
.
getFkClientId
(),
imMessageOnlineSend
);
log
.
info
(
"单用户在线下发耗时 {}"
,
System
.
currentTimeMillis
()
-
onlienTime
);
if
(
isPush
&&
!
sendSuccess
&&
!
member
.
getDoNotDisturb
())
{
if
(
isPush
&&
!
sendSuccess
&&
!
member
.
getDoNotDisturb
())
{
// 异步推送系统通知消息 5分钟内推一次消息
// 异步推送系统通知消息 5分钟内推一次消息
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
push
,
member
.
getFkClientId
(),
member
.
getClientId
(),
imApplication
);
PushDTO
pushDTO
=
mqSender
.
buildPushDto
(
push
,
member
.
getFkClientId
(),
member
.
getClientId
(),
imApplication
);
...
...
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
d52f4ed0
...
@@ -212,7 +212,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -212,7 +212,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
imMessage
.
setFkConversationId
(
sysParam
.
getToConversation
());
imMessage
.
setFkConversationId
(
sysParam
.
getToConversation
());
this
.
save
(
imMessage
);
this
.
save
(
imMessage
);
eventPublisher
.
publishEvent
(
new
ClientSendMessageEvent
(
imApplication
.
getId
(),
imMessage
));
//
eventPublisher.publishEvent(new ClientSendMessageEvent(imApplication.getId(), imMessage));
return
imMessage
;
return
imMessage
;
}
}
...
@@ -224,9 +224,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -224,9 +224,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
// 数据库字段类型为JSON格式
// 数据库字段类型为JSON格式
// 因mysql关系型数据库非MongoDB文档类型数据库,第三方应用拓展的自定义参数名和值需使用json格式落库
// 因mysql关系型数据库非MongoDB文档类型数据库,第三方应用拓展的自定义参数名和值需使用json格式落库
Long
jsonTime
=
System
.
currentTimeMillis
();
String
contentJsonString
=
JsonUtils
.
encodeJson
(
data
);
String
contentJsonString
=
JsonUtils
.
encodeJson
(
data
);
log
.
info
(
"encode json time {}"
,
System
.
currentTimeMillis
()-
jsonTime
);
imMessage
.
setContent
(
contentJsonString
);
imMessage
.
setContent
(
contentJsonString
);
imMessage
.
setId
(
SnowflakeUtil
.
getId
());
imMessage
.
setId
(
SnowflakeUtil
.
getId
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment