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
665de18a
Commit
665de18a
authored
Dec 22, 2021
by
lixiaozhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、避免系统重启产生redis大量脏数据
2、修复登录状态报错的bug
parent
97981223
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
31 deletions
+9
-31
core/src/main/java/com/wecloud/im/ws/cache/UserCacheService.java
+0
-9
core/src/main/java/com/wecloud/im/ws/cache/UserCacheServiceImpl.java
+9
-22
No files found.
core/src/main/java/com/wecloud/im/ws/cache/UserCacheService.java
View file @
665de18a
...
...
@@ -27,15 +27,6 @@ public interface UserCacheService {
public
void
offline
(
String
appKey
,
String
clientId
,
String
longChannelId
);
/**
* 根据用户id获取存在redis中的数据 例如绑定的服务器ip地址
*
* @param clientId
* @return
*/
public
ClientConnectionInfo
getById
(
String
appKey
,
String
clientId
);
/**
* 根据ClientId从redis获取client信息
*
* @param appKey
...
...
core/src/main/java/com/wecloud/im/ws/cache/UserCacheServiceImpl.java
View file @
665de18a
...
...
@@ -76,8 +76,15 @@ public class UserCacheServiceImpl implements UserCacheService {
@Override
public
void
online
(
String
appKey
,
String
clientId
,
String
longChannelId
)
{
log
.
info
(
"ws用户上线保存redis连接ip:"
+
InitIp
.
lAN_IP
,
",uid:"
+
longChannelId
);
redisUtils
.
addForSet
(
CLIENTS
+
appKey
+
clientId
,
longChannelId
);
// 先进行历史数据清理
Set
<
String
>
members
=
redisUtils
.
getForSetMembers
(
CLIENTS
+
appKey
+
clientId
);
if
(
members
!=
null
)
{
members
.
forEach
(
channelId
->
redisUtils
.
delKey
(
CLIENT_INFO
+
channelId
));
}
redisUtils
.
delKey
(
CLIENTS
+
appKey
+
clientId
);
redisUtils
.
addForSet
(
CLIENTS
+
appKey
+
clientId
,
longChannelId
);
redisUtils
.
hashset
(
CLIENT_INFO
+
longChannelId
,
LAN_IP
,
InitIp
.
lAN_IP
);
redisUtils
.
hashset
(
CLIENT_INFO
+
longChannelId
,
ONLINE_STATUS
,
ONLINE
.
toString
());
...
...
@@ -99,26 +106,6 @@ public class UserCacheServiceImpl implements UserCacheService {
redisUtils
.
delKey
(
CLIENT_INFO
+
longChannelId
);
}
/**
* 根据用户id获取存在redis中的数据 例如绑定的服务器ip地址
*
* @param clientId
* @return
*/
@Override
public
ClientConnectionInfo
getById
(
String
appKey
,
String
clientId
)
{
Map
<
String
,
String
>
hgetll
=
redisUtils
.
hashgetll
(
CLIENT_INFO
+
appKey
+
clientId
);
if
(
hgetll
.
isEmpty
())
{
return
null
;
}
ClientConnectionInfo
appHashValueModel
=
new
ClientConnectionInfo
();
appHashValueModel
.
setLanIp
(
hgetll
.
get
(
LAN_IP
));
// appHashValueModel.(Integer.parseInt(hgetll.get(ONLINE_STATUS_KEY)));
return
appHashValueModel
;
}
@Override
public
List
<
ClientChannelInfo
>
getIpByClientIdAndOnline
(
String
appKey
,
String
clientId
)
{
...
...
@@ -129,7 +116,7 @@ public class UserCacheServiceImpl implements UserCacheService {
// 根据 longChannelId 查询信息
for
(
String
longChannelId
:
longChannelIds
)
{
String
onlineStatus
=
redisUtils
.
hashget
(
CLIENT_INFO
+
appKey
+
client
Id
,
ONLINE_STATUS
);
String
onlineStatus
=
redisUtils
.
hashget
(
CLIENT_INFO
+
longChannel
Id
,
ONLINE_STATUS
);
String
lanIp
=
redisUtils
.
hashget
(
CLIENT_INFO
+
longChannelId
,
LAN_IP
);
ClientChannelInfo
clientChannelInfo
=
new
ClientChannelInfo
();
...
...
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