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
bd2e5899
Commit
bd2e5899
authored
Nov 20, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
未读消息添加在线用户未读消息数量添加
parent
0401697b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
10 deletions
+22
-10
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+6
-0
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+5
-0
core/src/main/java/com/wecloud/im/ws/manager/ChannelManager.java
+8
-0
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/MessageScheduled.java
+3
-10
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
bd2e5899
...
...
@@ -32,6 +32,7 @@ import com.wecloud.im.service.ImInboxService;
import
com.wecloud.im.service.ImMessageService
;
import
com.wecloud.im.ws.enums.MsgTypeEnum
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.manager.ChannelManager
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.im.ws.sender.ChannelSender
;
...
...
@@ -293,6 +294,11 @@ public class NormalChatAction {
if
(
clientSender
.
getClientId
().
equals
(
member
.
getClientId
()))
{
continue
;
}
Integer
count
=
ChannelManager
.
ONLINE_USER_MAP
.
get
(
String
.
valueOf
(
member
.
getFkClientId
()));
if
(
count
==
null
)
{
continue
;
}
ImInbox
imInbox
=
new
ImInbox
();
imInbox
.
setId
(
SnowflakeUtil
.
getId
());
imInbox
.
setCreateTime
(
new
Date
());
...
...
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
bd2e5899
...
...
@@ -56,6 +56,7 @@ import com.wecloud.im.vo.ReaderList;
import
com.wecloud.im.vo.ReaderVo
;
import
com.wecloud.im.ws.enums.MsgTypeEnum
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.manager.ChannelManager
;
import
com.wecloud.im.ws.model.WsResponse
;
import
com.wecloud.im.ws.model.request.PushVO
;
import
com.wecloud.im.ws.sender.ChannelSender
;
...
...
@@ -654,6 +655,10 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
if
(
senderClientId
.
equals
(
member
.
getClientId
()))
{
continue
;
}
Integer
count
=
ChannelManager
.
ONLINE_USER_MAP
.
get
(
String
.
valueOf
(
member
.
getFkClientId
()));
if
(
count
==
null
)
{
continue
;
}
ImInbox
imInbox
=
new
ImInbox
();
imInbox
.
setId
(
SnowflakeUtil
.
getId
());
imInbox
.
setCreateTime
(
new
Date
());
...
...
core/src/main/java/com/wecloud/im/ws/manager/ChannelManager.java
View file @
bd2e5899
...
...
@@ -30,6 +30,12 @@ public class ChannelManager {
public
static
final
Map
<
String
,
ClientInfo
>
SESSION_INFO_MAP
=
new
ConcurrentHashMap
<>();
/**
* 在线用户map 用于控制inbox表插入
* key: clientId
* value: 当天接收消息数量
*/
public
static
final
Map
<
String
,
Integer
>
ONLINE_USER_MAP
=
new
ConcurrentHashMap
<>();
/**
* CLIENT_ID,是客户端的字符串id
*/
public
static
final
AttributeKey
<
Long
>
CLIENT_ID
=
AttributeKey
.
valueOf
(
"ci"
);
...
...
@@ -62,6 +68,7 @@ public class ChannelManager {
String
longChannelId
=
channel
.
id
().
asLongText
();
log
.
info
(
"保存本地连接clientId {} platform {}"
,
clientId
,
platform
);
this
.
putSessionInfoMap
(
clientId
,
platform
,
channel
);
ChannelManager
.
ONLINE_USER_MAP
.
put
(
String
.
valueOf
(
clientId
),
1
);
UserStateListener
.
triggerOnlineEvent
(
clientId
,
platform
,
longChannelId
);
}
...
...
@@ -90,6 +97,7 @@ public class ChannelManager {
// 移除本地维护的channel
delSessionInfoMap
(
clientId
,
platform
);
ChannelManager
.
ONLINE_USER_MAP
.
remove
(
String
.
valueOf
(
clientId
));
UserStateListener
.
triggerOfflineEvent
(
clientId
,
platform
,
longChannelId
);
}
...
...
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/MessageScheduled.java
View file @
bd2e5899
...
...
@@ -30,23 +30,16 @@ public class MessageScheduled {
/**
* 离线消息处理定时器
* 15之前的离线消息直接删除
* 一星期前的已读消息 删除
* 7之前的离线消息直接删除
* 一天执行一次 凌晨3点执行
*/
@Scheduled
(
cron
=
"0 0 3 * * ?"
)
public
void
inboxDelete
()
{
log
.
info
(
"离线消息处理定时器处理开始..."
);
//
15
天之前数据, 直接删除
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
15
);
//
7
天之前数据, 直接删除
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
7
);
imInboxService
.
remove
(
new
QueryWrapper
<
ImInbox
>().
lambda
()
.
lt
(
ImInbox:
:
getCreateTime
,
allDeleteTime
));
// 7天之前数据, 删除已读消息
Date
readTime
=
DateUtils
.
addDays
(
new
Date
(),
-
7
);
imInboxService
.
remove
(
new
QueryWrapper
<
ImInbox
>().
lambda
()
.
eq
(
ImInbox:
:
getReadMsgStatus
,
1
)
.
lt
(
ImInbox:
:
getCreateTime
,
readTime
));
}
/**
...
...
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