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
36cd4e3e
Commit
36cd4e3e
authored
Sep 27, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
群聊消息添加多线程操作
parent
ebfb7f06
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
23 deletions
+41
-23
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+39
-21
core/src/main/java/com/wecloud/im/entity/ImConversationMembers.java
+1
-1
core/src/main/java/com/wecloud/im/executor/SendMsgThreadPool.java
+1
-1
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
36cd4e3e
...
@@ -13,6 +13,7 @@ import com.wecloud.im.entity.ImConversationMembers;
...
@@ -13,6 +13,7 @@ import com.wecloud.im.entity.ImConversationMembers;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.entity.ImMessageOnlineSend
;
import
com.wecloud.im.executor.SendMsgThreadPool
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.entity.ImFriend
;
import
com.wecloud.im.friend.service.ImFriendService
;
import
com.wecloud.im.friend.service.ImFriendService
;
import
com.wecloud.im.mq.MqSender
;
import
com.wecloud.im.mq.MqSender
;
...
@@ -166,23 +167,38 @@ public class NormalChatAction {
...
@@ -166,23 +167,38 @@ public class NormalChatAction {
// 入库 保存收件箱
// 入库 保存收件箱
batchSaveInbox
(
imApplication
,
conversation
,
imMessageOnlineSend
.
getMsgId
(),
membersList
);
batchSaveInbox
(
imApplication
,
conversation
,
imMessageOnlineSend
.
getMsgId
(),
membersList
);
// 再给所有人发
// 入库成功后 判断是否是临时会话 如果是,双方会话display状态是否是1(显示),如果不是,需要修改为是
for
(
ImConversationMembers
member
:
membersList
)
{
if
(
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
if
(
member
.
getFkClientId
().
equals
(
imClientSender
.
getId
()))
{
// 木有只有私聊一种临时会话类型
// 不给自己发
List
<
ImConversationMembers
>
tempMemberToUpdate
=
Lists
.
newArrayList
();
continue
;
for
(
ImConversationMembers
members
:
membersList
)
{
}
if
(
members
.
getDisplayStatus
()
==
0
)
{
// 入库成功后 判断是否是临时会话 如果是,双方会话display状态是否是1(显示),如果不是,需要修改为是
members
.
setDisplayStatus
(
1
);
if
(
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
conversation
.
getChatType
()))
{
tempMemberToUpdate
.
add
(
members
);
// 木有只有私聊一种临时会话类型
for
(
ImConversationMembers
members
:
membersList
)
{
members
.
setDisplayStatus
(
1L
);
}
}
imConversationMembersService
.
updateBatchById
(
membersList
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
tempMemberToUpdate
))
{
imConversationMembersService
.
updateBatchById
(
tempMemberToUpdate
);
}
}
// 多线程处理消息下发
for
(
ImConversationMembers
member
:
membersList
)
{
SendMsgThreadPool
.
SEND_MSG_THREAD_POOL_EXECUTOR
.
execute
(()
->
{
this
.
sendMsgToMember
(
member
,
imClientSender
,
imMessageOnlineSend
);
});
}
// 响应发送方消息id等信息
response
(
reqId
,
imMessageOnlineSend
.
getMsgId
(),
request
.
getSenderChannel
());
}
// 在线用户直接发消息
private
void
sendMsgToMember
(
ImConversationMembers
member
,
ImClient
imClientSender
,
ImMessageOnlineSend
imMessageOnlineSend
)
{
Boolean
sendSuccess
=
sendMsgForOnline
(
member
.
getFkClientId
(),
imMessageOnlineSend
);
if
(
member
.
getFkClientId
().
equals
(
imClientSender
.
getId
()))
{
// 不给自己发
return
;
}
// 在线用户直接发消息
Boolean
sendSuccess
=
sendMsgForOnline
(
member
.
getFkClientId
(),
imMessageOnlineSend
);
// if (!sendSuccess && !member.getDoNotDisturb()) {
// if (!sendSuccess && !member.getDoNotDisturb()) {
// // 异步推送系统通知消息
// // 异步推送系统通知消息
...
@@ -191,15 +207,11 @@ public class NormalChatAction {
...
@@ -191,15 +207,11 @@ public class NormalChatAction {
// mqSender.orderSend(MqConstant.Topic.IM_ORDER_MSG_TOPIC, MqConstant.Tag.IM_ORDER_MSG_TAG, pushDTO);
// mqSender.orderSend(MqConstant.Topic.IM_ORDER_MSG_TOPIC, MqConstant.Tag.IM_ORDER_MSG_TAG, pushDTO);
// }
// }
// }
// }
}
// 响应发送方消息id等信息
response
(
reqId
,
imMessageOnlineSend
.
getMsgId
(),
request
.
getSenderChannel
());
}
}
/**
/**
* 发送消息给在线客户
* 发送消息给在线客户
*
* @param receiverClientId
* @param receiverClientId
* @param imMessageOnlineSend
* @param imMessageOnlineSend
*/
*/
...
@@ -217,6 +229,7 @@ public class NormalChatAction {
...
@@ -217,6 +229,7 @@ public class NormalChatAction {
/**
/**
* 拼装发送消息体
* 拼装发送消息体
*
* @param data
* @param data
* @param imClientSender
* @param imClientSender
* @param appId
* @param appId
...
@@ -344,9 +357,10 @@ public class NormalChatAction {
...
@@ -344,9 +357,10 @@ public class NormalChatAction {
/**
/**
* 好友判断
* 好友判断
*
* @param
* @Author luozh
* @Author luozh
* @Date 2022年05月18日 07:28:34
* @Date 2022年05月18日 07:28:34
* @param
* @Return
* @Return
*/
*/
private
boolean
friend
(
String
reqId
,
ImClient
imClientSender
,
Long
conversationId
,
private
boolean
friend
(
String
reqId
,
ImClient
imClientSender
,
Long
conversationId
,
...
@@ -450,6 +464,7 @@ public class NormalChatAction {
...
@@ -450,6 +464,7 @@ public class NormalChatAction {
/**
/**
* 判断被踢出逻辑
* 判断被踢出逻辑
*
* @param reqId
* @param reqId
* @param imClientSender
* @param imClientSender
* @param membersList
* @param membersList
...
@@ -477,6 +492,7 @@ public class NormalChatAction {
...
@@ -477,6 +492,7 @@ public class NormalChatAction {
/**
/**
* 是否禁言判断
* 是否禁言判断
*
* @param conversation
* @param conversation
* @param reqId
* @param reqId
* @param imClientSender
* @param imClientSender
...
@@ -519,9 +535,10 @@ public class NormalChatAction {
...
@@ -519,9 +535,10 @@ public class NormalChatAction {
/**
/**
* 是否封禁
* 是否封禁
*
* @param
* @Author Shadow
* @Author Shadow
* @Date 2022年06月06日 01:42:33
* @Date 2022年06月06日 01:42:33
* @param
* @Return
* @Return
*/
*/
private
boolean
baned
(
ImConversationQueryVo
conversation
,
String
reqId
,
ImClient
imClientSender
,
List
<
ImConversationMembers
>
membersList
,
Channel
channel
)
{
private
boolean
baned
(
ImConversationQueryVo
conversation
,
String
reqId
,
ImClient
imClientSender
,
List
<
ImConversationMembers
>
membersList
,
Channel
channel
)
{
...
@@ -553,6 +570,7 @@ public class NormalChatAction {
...
@@ -553,6 +570,7 @@ public class NormalChatAction {
/**
/**
* 是否禁止发送链接
* 是否禁止发送链接
*
* @Author luozh
* @Author luozh
* @Date 2022年04月27日 04:39:04
* @Date 2022年04月27日 04:39:04
* @Return
* @Return
...
...
core/src/main/java/com/wecloud/im/entity/ImConversationMembers.java
View file @
36cd4e3e
...
@@ -56,7 +56,7 @@ public class ImConversationMembers extends BaseEntity {
...
@@ -56,7 +56,7 @@ public class ImConversationMembers extends BaseEntity {
@NotNull
(
message
=
"单向删除(隐藏)会话, 0不显示, 1显示不能为空"
)
@NotNull
(
message
=
"单向删除(隐藏)会话, 0不显示, 1显示不能为空"
)
@ApiModelProperty
(
"单向删除(隐藏)会话, 0不显示, 1显示"
)
@ApiModelProperty
(
"单向删除(隐藏)会话, 0不显示, 1显示"
)
private
Long
displayStatus
;
private
Integer
displayStatus
;
@ApiModelProperty
(
"会话中client的备注名"
)
@ApiModelProperty
(
"会话中client的备注名"
)
private
String
clientRemarkName
;
private
String
clientRemarkName
;
...
...
core/src/main/java/com/wecloud/im/executor/SendMsgThreadPool.java
View file @
36cd4e3e
...
@@ -18,7 +18,7 @@ public class SendMsgThreadPool {
...
@@ -18,7 +18,7 @@ public class SendMsgThreadPool {
.
setNamePrefix
(
"-sendM-"
).
build
();
.
setNamePrefix
(
"-sendM-"
).
build
();
/**
/**
*
业务
处理线程池
*
消息下发
处理线程池
*/
*/
public
static
final
ExecutorService
SEND_MSG_THREAD_POOL_EXECUTOR
=
public
static
final
ExecutorService
SEND_MSG_THREAD_POOL_EXECUTOR
=
new
ThreadPoolExecutor
(
WsConstants
.
CPU_PROCESSORS
,
WsConstants
.
CPU_PROCESSORS
*
3
,
new
ThreadPoolExecutor
(
WsConstants
.
CPU_PROCESSORS
,
WsConstants
.
CPU_PROCESSORS
*
3
,
...
...
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