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
72bf9ae6
Commit
72bf9ae6
authored
Sep 26, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
注释部分日志打印
parent
e0cc1db3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
bootstrap/src/test/java/io/geekidea/springbootplus/test/SaveApnsTest.java
+0
-2
core/src/main/java/com/wecloud/im/ws/sender/ChannelSender.java
+13
-13
No files found.
bootstrap/src/test/java/io/geekidea/springbootplus/test/SaveApnsTest.java
View file @
72bf9ae6
...
@@ -3,7 +3,6 @@ package io.geekidea.springbootplus.test;
...
@@ -3,7 +3,6 @@ package io.geekidea.springbootplus.test;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.codec.Base64
;
import
com.wecloud.im.entity.ImIosApns
;
import
com.wecloud.im.entity.ImIosApns
;
import
com.wecloud.im.service.ImIosApnsService
;
import
com.wecloud.im.service.ImIosApnsService
;
import
com.wecloud.im.ws.sender.IosPush
;
import
com.wecloud.utils.SnowflakeUtil
;
import
com.wecloud.utils.SnowflakeUtil
;
import
io.geekidea.springbootplus.SpringBootPlusApplication
;
import
io.geekidea.springbootplus.SpringBootPlusApplication
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -16,7 +15,6 @@ import java.io.File;
...
@@ -16,7 +15,6 @@ import java.io.File;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
/**
* 生成apns字符串 并存入数据库
* 生成apns字符串 并存入数据库
...
...
core/src/main/java/com/wecloud/im/ws/sender/ChannelSender.java
View file @
72bf9ae6
...
@@ -135,23 +135,23 @@ public class ChannelSender {
...
@@ -135,23 +135,23 @@ public class ChannelSender {
String
msgJson
=
JsonUtils
.
encodeJson
(
responseModel
);
String
msgJson
=
JsonUtils
.
encodeJson
(
responseModel
);
List
<
ClientChannelInfo
>
channelInfos
=
userStateCacheManager
.
findOnlineInfosByClientId
(
toClientId
);
List
<
ClientChannelInfo
>
channelInfos
=
userStateCacheManager
.
findOnlineInfosByClientId
(
toClientId
);
log
.
info
(
"获取在线用户入参 {}, 结果 {}"
,
toClientId
,
JSON
.
toJSONString
(
channelInfos
));
//
log.info("获取在线用户入参 {}, 结果 {}", toClientId, JSON.toJSONString(channelInfos));
// 一个用户存在多端的情况,所以先进行分类,key是ip地址,value是channel的列表
// 一个用户存在多端的情况,所以先进行分类,key是ip地址,value是channel的列表
Map
<
String
,
List
<
ClientChannelInfo
>>
ipChannels
=
channelInfos
.
stream
().
collect
(
Collectors
.
groupingBy
(
ClientChannelInfo:
:
getLanIp
));
Map
<
String
,
List
<
ClientChannelInfo
>>
ipChannels
=
channelInfos
.
stream
().
collect
(
Collectors
.
groupingBy
(
ClientChannelInfo:
:
getLanIp
));
log
.
info
(
"分组在线用户入参 {}, 结果 {}"
,
toClientId
,
JSON
.
toJSONString
(
ipChannels
));
//
log.info("分组在线用户入参 {}, 结果 {}", toClientId, JSON.toJSONString(ipChannels));
for
(
Map
.
Entry
<
String
,
List
<
ClientChannelInfo
>>
channelInfoEntry
:
ipChannels
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
ClientChannelInfo
>>
channelInfoEntry
:
ipChannels
.
entrySet
())
{
log
.
info
(
"在线用户入参 {}, 具体ip结果 {}"
,
toClientId
,
JSON
.
toJSONString
(
channelInfoEntry
));
//
log.info("在线用户入参 {}, 具体ip结果 {}", toClientId, JSON.toJSONString(channelInfoEntry));
// 是否为当前机器的ip
// 是否为当前机器的ip
if
(
GetIpUtils
.
getlanIp
().
equals
(
channelInfoEntry
.
getKey
()))
{
if
(
GetIpUtils
.
getlanIp
().
equals
(
channelInfoEntry
.
getKey
()))
{
// 调用本地下发
// 调用本地下发
log
.
info
(
"在线用户入参 {}, 具体ip结果 {}"
,
toClientId
,
JSON
.
toJSONString
(
channelInfoEntry
));
//
log.info("在线用户入参 {}, 具体ip结果 {}", toClientId, JSON.toJSONString(channelInfoEntry));
for
(
ClientChannelInfo
clientChannelInfo
:
channelInfoEntry
.
getValue
())
{
for
(
ClientChannelInfo
clientChannelInfo
:
channelInfoEntry
.
getValue
())
{
log
.
info
(
"客户端 {}, 推送消息内容 {}"
,
toClientId
,
msgJson
);
//
log.info("客户端 {}, 推送消息内容 {}", toClientId, msgJson);
this
.
sendMsgLocal
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
this
.
sendMsgLocal
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
}
}
continue
;
continue
;
...
@@ -163,13 +163,13 @@ public class ChannelSender {
...
@@ -163,13 +163,13 @@ public class ChannelSender {
// dubbo指定ip调用
// dubbo指定ip调用
Address
address
=
new
Address
(
clientChannelInfo
.
getLanIp
(),
20882
);
Address
address
=
new
Address
(
clientChannelInfo
.
getLanIp
(),
20882
);
RpcContext
.
getContext
().
setObjectAttachment
(
"address"
,
address
);
RpcContext
.
getContext
().
setObjectAttachment
(
"address"
,
address
);
log
.
info
(
"dubbo指定ip调用 {}"
,
JSON
.
toJSONString
(
address
));
//
log.info("dubbo指定ip调用 {}", JSON.toJSONString(address));
try
{
try
{
routerSendService
.
sendMsgRemote
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
routerSendService
.
sendMsgRemote
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
}
catch
(
RpcException
exception
)
{
}
catch
(
RpcException
exception
)
{
// do nothing is ok
// do nothing is ok
tryFindAndSendAndRefresh
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
tryFindAndSendAndRefresh
(
toClientId
,
clientChannelInfo
.
getPlatform
(),
msgJson
);
log
.
info
(
"rpc 调用异常 {} "
,
JSON
.
toJSONString
(
clientChannelInfo
));
//
log.info("rpc 调用异常 {} ", JSON.toJSONString(clientChannelInfo));
}
}
}
}
}
}
...
@@ -186,7 +186,7 @@ public class ChannelSender {
...
@@ -186,7 +186,7 @@ public class ChannelSender {
* @Return
* @Return
*/
*/
public
void
tryFindAndSendAndRefresh
(
Long
toClientId
,
Integer
platform
,
String
msg
)
{
public
void
tryFindAndSendAndRefresh
(
Long
toClientId
,
Integer
platform
,
String
msg
)
{
log
.
info
(
"触发tryFindAndSendAndRefresh {} {}"
,
toClientId
,
platform
);
//
log.info("触发tryFindAndSendAndRefresh {} {}", toClientId, platform);
this
.
sendMsgLocal
(
toClientId
,
platform
,
msg
);
this
.
sendMsgLocal
(
toClientId
,
platform
,
msg
);
}
}
...
@@ -251,25 +251,25 @@ public class ChannelSender {
...
@@ -251,25 +251,25 @@ public class ChannelSender {
* @return
* @return
*/
*/
private
boolean
sendMsgLocal
(
String
key
,
String
msgJsonStr
)
{
private
boolean
sendMsgLocal
(
String
key
,
String
msgJsonStr
)
{
log
.
info
(
"消息推送 key {} 内容 {}"
,
key
,
msgJsonStr
);
//
log.info("消息推送 key {} 内容 {}", key, msgJsonStr);
ClientInfo
clientInfo
=
ChannelManager
.
SESSION_INFO_MAP
.
get
(
key
);
ClientInfo
clientInfo
=
ChannelManager
.
SESSION_INFO_MAP
.
get
(
key
);
if
(
clientInfo
==
null
)
{
if
(
clientInfo
==
null
)
{
log
.
info
(
"消息推送 key {} 本地map取设备信息为空"
,
key
);
//
log.info("消息推送 key {} 本地map取设备信息为空", key);
return
false
;
return
false
;
}
}
NioSocketChannel
nioSocketChannel
=
clientInfo
.
getNioSocketChannel
();
NioSocketChannel
nioSocketChannel
=
clientInfo
.
getNioSocketChannel
();
if
(
null
==
nioSocketChannel
)
{
if
(
null
==
nioSocketChannel
)
{
log
.
info
(
"writeData连接为空: {}"
,
msgJsonStr
);
//
log.info("writeData连接为空: {}", msgJsonStr);
return
false
;
return
false
;
}
}
// 判断连接是否断开
// 判断连接是否断开
if
(
nioSocketChannel
.
isShutdown
())
{
if
(
nioSocketChannel
.
isShutdown
())
{
log
.
info
(
"writeData 已连接断开: {}\n channelId: {}"
,
msgJsonStr
,
nioSocketChannel
.
id
().
asLongText
());
//
log.info("writeData 已连接断开: {}\n channelId: {}", msgJsonStr, nioSocketChannel.id().asLongText());
return
false
;
return
false
;
}
}
log
.
info
(
"writeData, channelId: {}"
,
nioSocketChannel
.
id
().
asLongText
());
//
log.info("writeData, channelId: {}", nioSocketChannel.id().asLongText());
nioSocketChannel
.
writeAndFlush
(
new
TextWebSocketFrame
(
msgJsonStr
));
nioSocketChannel
.
writeAndFlush
(
new
TextWebSocketFrame
(
msgJsonStr
));
...
...
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