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
a057f7c2
Commit
a057f7c2
authored
Oct 17, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
内存泄露问题处理
parent
43d23543
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
68 deletions
+19
-68
core/src/main/java/com/wecloud/im/balance/WsInstance.java
+0
-37
core/src/main/java/com/wecloud/im/service/impl/ImClientLoginServiceImpl.java
+19
-31
No files found.
core/src/main/java/com/wecloud/im/balance/WsInstance.java
deleted
100644 → 0
View file @
43d23543
package
com
.
wecloud
.
im
.
balance
;
import
com.alibaba.nacos.api.exception.NacosException
;
import
com.alibaba.nacos.api.naming.NamingFactory
;
import
com.alibaba.nacos.api.naming.NamingService
;
import
com.alibaba.nacos.api.naming.pojo.Instance
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.Map
;
import
static
com
.
wecloud
.
im
.
ws
.
model
.
WsConstants
.
IP_NETTY_PUBLIC
;
@Component
@Slf4j
public
class
WsInstance
{
@Value
(
"${spring.cloud.nacos.discovery.server-addr}"
)
private
String
addr
;
/**
* 返回一个健康实例的公网ip
*
* @return
* @throws NacosException
*/
public
String
selectOneHealthyInstance
()
throws
NacosException
{
NamingService
naming
=
NamingFactory
.
createNamingService
(
addr
);
Instance
wecloudIm
=
naming
.
selectOneHealthyInstance
(
"wecloud_im"
);
Map
<
String
,
String
>
metadata
=
wecloudIm
.
getMetadata
();
String
publicIp
=
metadata
.
get
(
IP_NETTY_PUBLIC
);
log
.
info
(
"get_wecloud_im_publicIp:"
+
publicIp
);
return
publicIp
;
}
}
core/src/main/java/com/wecloud/im/service/impl/ImClientLoginServiceImpl.java
View file @
a057f7c2
package
com
.
wecloud
.
im
.
service
.
impl
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
io.geekidea.springbootplus.framework.shiro.util.SecurityUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.time.Duration
;
import
java.util.Date
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
cn.hutool.crypto.digest.MD5
;
import
com.alibaba.nacos.api.exception.NacosException
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.wecloud.im.balance.WsInstance
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImClientDevice
;
...
...
@@ -31,17 +12,25 @@ import com.wecloud.im.service.ImClientLoginService;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.vo.TokenVo
;
import
com.wecloud.utils.SnowflakeUtil
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.shiro.cache.AppLoginRedisService
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
io.geekidea.springbootplus.framework.shiro.util.SecurityUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.Duration
;
import
java.util.Date
;
@Service
@Slf4j
public
class
ImClientLoginServiceImpl
implements
ImClientLoginService
{
// @Autowired
// private RedisUtils redisUtils;
// @Autowired
// private StringRedisTemplate redisTemplate;
private
static
JwtProperties
jwtProperties
;
@Autowired
private
ImApplicationService
imApplicationService
;
...
...
@@ -51,8 +40,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
@Autowired
private
ImClientService
imClientService
;
@Autowired
private
WsInstance
wsInstance
;
@Autowired
private
AppLoginRedisService
appLoginRedisService
;
...
...
@@ -69,7 +57,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ApiResult
<
TokenVo
>
verifySign
(
ImTokenVerify
imTokenVerify
)
throws
NacosException
{
public
ApiResult
<
TokenVo
>
verifySign
(
ImTokenVerify
imTokenVerify
)
{
// 根据appKey从数据库查询密钥
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
imTokenVerify
.
getAppKey
());
...
...
@@ -119,14 +107,14 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
TokenVo
tokenVo
=
new
TokenVo
();
tokenVo
.
setToken
(
generateToken
);
tokenVo
.
setWsAddr
(
wsInstance
.
selectOneHealthyInstance
()
);
tokenVo
.
setWsAddr
(
""
);
tokenVo
.
setId
(
imClient
.
getId
());
tokenVo
.
setAttributes
(
imClient
.
getAttributes
());
return
ApiResult
.
ok
(
tokenVo
);
}
@Override
public
ApiResult
<
TokenVo
>
getToken
(
String
clientId
,
Integer
deviceType
)
throws
NacosException
{
public
ApiResult
<
TokenVo
>
getToken
(
String
clientId
,
Integer
deviceType
)
{
Long
appId
=
SecurityUtils
.
getCurrentAppId
();
String
appKey
=
SecurityUtils
.
getCurrentAppKey
();
ImApplication
imApplication
=
imApplicationService
.
getCacheAppByAppKey
(
appKey
);
...
...
@@ -169,7 +157,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
TokenVo
tokenVo
=
new
TokenVo
();
tokenVo
.
setToken
(
generateToken
);
tokenVo
.
setWsAddr
(
wsInstance
.
selectOneHealthyInstance
()
);
tokenVo
.
setWsAddr
(
""
);
tokenVo
.
setId
(
client
.
getId
());
tokenVo
.
setAttributes
(
client
.
getAttributes
());
return
ApiResult
.
ok
(
tokenVo
);
...
...
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