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
7b2511a7
Commit
7b2511a7
authored
Dec 06, 2021
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息事件类型 封装枚举类;
优化代码,移除无用TODO;
parent
b4774b23
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
69 deletions
+92
-69
common/src/main/java/com/wecloud/im/push/PushUtils.java
+21
-21
common/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
+1
-1
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+6
-6
common/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
+3
-2
common/src/main/java/com/wecloud/im/ws/enums/MsgTypeEnum.java
+58
-0
common/src/main/java/com/wecloud/im/ws/enums/WsResponseEventEnum.java
+0
-36
common/src/main/java/com/wecloud/im/ws/service/impl/MangerChannelServiceImpl.java
+3
-3
No files found.
common/src/main/java/com/wecloud/im/push/PushUtils.java
View file @
7b2511a7
...
...
@@ -34,7 +34,7 @@ public class PushUtils {
}
public
static
void
main
(
String
[]
args
)
{
//
TODO
set your appkey and master secret here
// set your appkey and master secret here
PushUtils
demo
=
new
PushUtils
(
"your appkey"
,
"your master secret"
);
try
{
...
...
@@ -52,7 +52,7 @@ public class PushUtils {
String
body
=
"今日可能下雨🌂"
;
demo
.
sendIOSUnicast
(
deviceTokenIOS
,
titleIOS
,
subtitle
,
body
);
/*
TODO
these methods are all available, just fill in some fields and do the test
/* these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
...
...
@@ -76,7 +76,7 @@ public class PushUtils {
broadcast
.
setText
(
"Android broadcast text"
);
broadcast
.
goAppAfterOpen
();
broadcast
.
setDisplayType
(
AndroidNotification
.
DisplayType
.
NOTIFICATION
);
//
TODO
Set 'production_mode' to 'false' if it's a test device.
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
broadcast
.
setProductionMode
();
// Set customized fields
...
...
@@ -98,7 +98,7 @@ public class PushUtils {
*/
public
void
sendAndroidUnicast
(
String
deviceToken
,
String
unicastText
,
String
unicastTicker
,
String
title
)
throws
Exception
{
AndroidUnicast
unicast
=
new
AndroidUnicast
(
appkey
,
appMasterSecret
);
//
TODO
Set your device token
// Set your device token
unicast
.
setDeviceToken
(
deviceToken
);
...
...
@@ -108,7 +108,7 @@ public class PushUtils {
unicast
.
setText
(
unicastText
);
unicast
.
goAppAfterOpen
();
unicast
.
setDisplayType
(
AndroidNotification
.
DisplayType
.
NOTIFICATION
);
//
TODO
Set 'production_mode' to 'false' if it's a test device.
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
unicast
.
setProductionMode
();
// Set customized fields
...
...
@@ -120,7 +120,7 @@ public class PushUtils {
public
void
sendAndroidGroupcast
()
throws
Exception
{
AndroidGroupcast
groupcast
=
new
AndroidGroupcast
(
appkey
,
appMasterSecret
);
/*
TODO
/*
* Construct the filter condition:
* "where":
* {
...
...
@@ -150,7 +150,7 @@ public class PushUtils {
groupcast
.
goAppAfterOpen
();
groupcast
.
setDisplayType
(
AndroidNotification
.
DisplayType
.
NOTIFICATION
);
groupcast
.
setChannelActivity
(
"your channel activity"
);
//
TODO
Set 'production_mode' to 'false' if it's a test device.
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
groupcast
.
setProductionMode
();
//厂商通道相关参数
...
...
@@ -161,7 +161,7 @@ public class PushUtils {
public
void
sendAndroidCustomizedcast
()
throws
Exception
{
AndroidCustomizedcast
customizedcast
=
new
AndroidCustomizedcast
(
appkey
,
appMasterSecret
);
//
TODO
Set your alias here, and use comma to split them if there are multiple alias.
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast
.
setAlias
(
"alias"
,
"alias_type"
);
...
...
@@ -170,7 +170,7 @@ public class PushUtils {
customizedcast
.
setText
(
"Android customizedcast text"
);
customizedcast
.
goAppAfterOpen
();
customizedcast
.
setDisplayType
(
AndroidNotification
.
DisplayType
.
NOTIFICATION
);
//
TODO
Set 'production_mode' to 'false' if it's a test device.
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast
.
setProductionMode
();
//厂商通道相关参数
...
...
@@ -181,7 +181,7 @@ public class PushUtils {
public
void
sendAndroidCustomizedcastFile
()
throws
Exception
{
AndroidCustomizedcast
customizedcast
=
new
AndroidCustomizedcast
(
appkey
,
appMasterSecret
);
//
TODO
Set your alias here, and use comma to split them if there are multiple alias.
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
String
fileId
=
client
.
uploadContents
(
appkey
,
appMasterSecret
,
"aa"
+
"\n"
+
"bb"
+
"\n"
+
"alias"
);
...
...
@@ -191,7 +191,7 @@ public class PushUtils {
customizedcast
.
setText
(
"Android customizedcast text"
);
customizedcast
.
goAppAfterOpen
();
customizedcast
.
setDisplayType
(
AndroidNotification
.
DisplayType
.
NOTIFICATION
);
//
TODO
Set 'production_mode' to 'false' if it's a test device.
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast
.
setProductionMode
();
//厂商通道相关参数
...
...
@@ -202,7 +202,7 @@ public class PushUtils {
public
void
sendAndroidFilecast
()
throws
Exception
{
AndroidFilecast
filecast
=
new
AndroidFilecast
(
appkey
,
appMasterSecret
);
//
TODO
upload your device tokens, and use '\n' to split them if there are multiple tokens
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String
fileId
=
client
.
uploadContents
(
appkey
,
appMasterSecret
,
"aa"
+
"\n"
+
"bb"
);
filecast
.
setFileId
(
fileId
);
filecast
.
setTicker
(
"Android filecast ticker"
);
...
...
@@ -224,7 +224,7 @@ public class PushUtils {
broadcast
.
setAlert
(
"今日天气"
,
""
,
"今日可能下雨🌂"
);
broadcast
.
setBadge
(
0
);
broadcast
.
setSound
(
"default"
);
//
TODO
set 'production_mode' to 'true' if your app is under production mode
// set 'production_mode' to 'true' if your app is under production mode
broadcast
.
setTestMode
();
// Set customized fields
broadcast
.
setCustomizedField
(
"test"
,
"helloworld"
);
...
...
@@ -243,7 +243,7 @@ public class PushUtils {
*/
public
void
sendIOSUnicast
(
String
deviceToken
,
String
title
,
String
subtitle
,
String
body
)
throws
Exception
{
IOSUnicast
unicast
=
new
IOSUnicast
(
appkey
,
appMasterSecret
);
//
TODO
Set your device token
// Set your device token
unicast
.
setDeviceToken
(
deviceToken
);
//alert值设置为字符串
...
...
@@ -253,7 +253,7 @@ public class PushUtils {
unicast
.
setAlert
(
title
,
subtitle
,
body
);
unicast
.
setBadge
(
0
);
unicast
.
setSound
(
"default"
);
//
TODO
set 'production_mode' to 'true' if your app is under production mode
// set 'production_mode' to 'true' if your app is under production mode
unicast
.
setTestMode
();
// Set customized fields
unicast
.
setCustomizedField
(
"test"
,
"helloworld"
);
...
...
@@ -262,7 +262,7 @@ public class PushUtils {
public
void
sendIOSGroupcast
()
throws
Exception
{
IOSGroupcast
groupcast
=
new
IOSGroupcast
(
appkey
,
appMasterSecret
);
/*
TODO
/*
* Construct the filter condition:
* "where":
* {
...
...
@@ -289,14 +289,14 @@ public class PushUtils {
groupcast
.
setAlert
(
"今日天气"
,
"subtitle"
,
"今日可能下雨🌂"
);
groupcast
.
setBadge
(
0
);
groupcast
.
setSound
(
"default"
);
//
TODO
set 'production_mode' to 'true' if your app is under production mode
// set 'production_mode' to 'true' if your app is under production mode
groupcast
.
setTestMode
();
client
.
send
(
groupcast
);
}
public
void
sendIOSCustomizedcast
()
throws
Exception
{
IOSCustomizedcast
customizedcast
=
new
IOSCustomizedcast
(
appkey
,
appMasterSecret
);
//
TODO
Set your alias and alias_type here, and use comma to split them if there are multiple alias.
// Set your alias and alias_type here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast
.
setAlias
(
"alias"
,
"alias_type"
);
...
...
@@ -305,14 +305,14 @@ public class PushUtils {
customizedcast
.
setAlert
(
"今日天气"
,
""
,
"今日可能下雨🌂"
);
customizedcast
.
setBadge
(
0
);
customizedcast
.
setSound
(
"default"
);
//
TODO
set 'production_mode' to 'true' if your app is under production mode
// set 'production_mode' to 'true' if your app is under production mode
customizedcast
.
setTestMode
();
client
.
send
(
customizedcast
);
}
public
void
sendIOSFilecast
()
throws
Exception
{
IOSFilecast
filecast
=
new
IOSFilecast
(
appkey
,
appMasterSecret
);
//
TODO
upload your device tokens, and use '\n' to split them if there are multiple tokens
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String
fileId
=
client
.
uploadContents
(
appkey
,
appMasterSecret
,
"aa"
+
"\n"
+
"bb"
);
filecast
.
setFileId
(
fileId
);
//filecast.setAlert("IOS 文件播测试");
...
...
@@ -320,7 +320,7 @@ public class PushUtils {
filecast
.
setAlert
(
"今日天气"
,
""
,
"今日可能下雨🌂"
);
filecast
.
setBadge
(
0
);
filecast
.
setSound
(
"default"
);
//
TODO
set 'production_mode' to 'true' if your app is under production mode
// set 'production_mode' to 'true' if your app is under production mode
filecast
.
setTestMode
();
client
.
send
(
filecast
);
}
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationMembersServiceImpl.java
View file @
7b2511a7
...
...
@@ -121,7 +121,7 @@ public class ImConversationMembersServiceImpl extends BaseServiceImpl<ImConversa
boolean
b
=
imConversationMembersService
.
updateById
(
imConversationMember
);
if
(
b
)
{
//TODO ws下发群成员
属性
变动事件
//TODO ws下发群成员
备注
变动事件
return
ApiResult
.
ok
();
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
7b2511a7
...
...
@@ -30,6 +30,7 @@ import com.wecloud.im.service.ImMessageService;
import
com.wecloud.im.vo.ImConversationCreateVo
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
com.wecloud.im.vo.OfflineMsgDto
;
import
com.wecloud.im.ws.enums.MsgTypeEnum
;
import
com.wecloud.im.ws.enums.WsResponseCmdEnum
;
import
com.wecloud.im.ws.model.WsResponseModel
;
import
com.wecloud.im.ws.service.WriteDataService
;
...
...
@@ -284,11 +285,10 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"operator"
,
imClientSender
.
getClientId
());
//操作的client ID
content
.
put
(
"passivityOperator"
,
client2
.
getClientId
());
//被操作的client ID
content
.
put
(
"type"
,
-
1007
);
//xx邀请xx加入会话 -1007
content
.
put
(
"type"
,
MsgTypeEnum
.
INVITE_CLIENT_JOIN_CONVERSATION
.
getUriCode
()
);
//xx邀请xx加入会话 -1007
try
{
String
asString
=
JSON_MAPPER
.
writeValueAsString
(
content
);
imMessage
.
setContent
(
asString
);
String
contentString
=
JSON_MAPPER
.
writeValueAsString
(
content
);
imMessage
.
setContent
(
contentString
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -401,7 +401,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"operator"
,
imClientSender
.
getClientId
());
//操作的client ID
content
.
put
(
"passivityOperator"
,
client2
.
getClientId
());
//被操作的client ID
content
.
put
(
"type"
,
-
1008
);
//xx被xx移出会话 -1008
content
.
put
(
"type"
,
MsgTypeEnum
.
REMOVE_CLIENT_CONVERSATION
.
getUriCode
()
);
//xx被xx移出会话 -1008
try
{
String
asString
=
JSON_MAPPER
.
writeValueAsString
(
content
);
imMessage
.
setContent
(
asString
);
...
...
@@ -510,7 +510,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
ImMessage
imMessage
=
new
ImMessage
();
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
-
1012
);
// xx主动退出会话
content
.
put
(
"type"
,
MsgTypeEnum
.
LEAVE_CONVERSATION
.
getUriCode
()
);
// xx主动退出会话
try
{
String
asString
=
JSON_MAPPER
.
writeValueAsString
(
content
);
imMessage
.
setContent
(
asString
);
...
...
common/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
View file @
7b2511a7
...
...
@@ -15,6 +15,7 @@ import com.wecloud.im.service.ImClientService;
import
com.wecloud.im.service.ImConversationMembersService
;
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.model.WsResponseModel
;
import
com.wecloud.im.ws.service.WriteDataService
;
...
...
@@ -101,7 +102,7 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
// 内容
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
stringStringHashMap
.
put
(
"type"
,
"-1009
"
);
stringStringHashMap
.
put
(
"type"
,
MsgTypeEnum
.
CLIENT_RECEIVED_MSG
.
getUriCode
()
+
"
"
);
stringStringHashMap
.
put
(
"receiverId"
,
curentClient
.
getClientId
());
// 推送给接收方
...
...
@@ -144,7 +145,7 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
// 内容
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
stringStringHashMap
.
put
(
"type"
,
"-1010
"
);
stringStringHashMap
.
put
(
"type"
,
MsgTypeEnum
.
CLIENT_READ_MSG
+
"
"
);
stringStringHashMap
.
put
(
"receiverId"
,
curentClient
.
getClientId
());
sendMsgStatus
(
curentClient
,
application
,
stringStringHashMap
,
imMsgReadStatusUpdate
.
getMsgIds
());
...
...
common/src/main/java/com/wecloud/im/ws/enums/MsgTypeEnum.java
0 → 100644
View file @
7b2511a7
package
com
.
wecloud
.
im
.
ws
.
enums
;
/**
* @Description ws响应类型
* @Author xxxname xxxemail.com
* @Date 2019-12-05
*/
public
enum
MsgTypeEnum
{
// xx邀请xx加入会话 -1007
INVITE_CLIENT_JOIN_CONVERSATION
(-
1007
),
// xx被xx移出会话 -1008
REMOVE_CLIENT_CONVERSATION
(-
1008
),
// xx已接收某消息 -1009
CLIENT_RECEIVED_MSG
(-
1009
),
// xx已读某条消息 -1010
CLIENT_READ_MSG
(-
1010
),
// 你被xx拉入新会话 -1011
CLIENT_JOIN_NEW_CONVERSATION
(-
1011
),
// 主动退出会话 -1012
LEAVE_CONVERSATION
(-
1012
),
// 成为新群主 -1013
CONVERSATION_NEW_CREATOR
(-
1013
),
;
private
final
int
uriCode
;
MsgTypeEnum
(
int
uriCode
)
{
this
.
uriCode
=
uriCode
;
}
/**
* 根据uriCode获取
*
* @param uriCode
* @return
*/
public
static
MsgTypeEnum
getByCode
(
int
uriCode
)
{
for
(
MsgTypeEnum
wsResponsePathEnum
:
values
())
{
if
(
wsResponsePathEnum
.
getUriCode
()
==
uriCode
)
{
return
wsResponsePathEnum
;
}
}
return
null
;
}
public
int
getUriCode
()
{
return
uriCode
;
}
}
common/src/main/java/com/wecloud/im/ws/enums/WsResponseEventEnum.java
deleted
100644 → 0
View file @
b4774b23
package
com
.
wecloud
.
im
.
ws
.
enums
;
/**
* @Description ws响应类型
* @Author hewei hwei1233@163.com
* @Date 2019-12-05
*/
public
enum
WsResponseEventEnum
{
// - xx邀请xx加入会话 -1007
// - xx被xx移出会话 -1008
// - xx已接收某消息 -1009
// - xx已读某条消息 -1010
// - 你被xx拉入新会话 -1011
// - xx主动退出会话 -1012
// - xx成为新群主 -1013
/**
* 响应数据类型
*/
RES
(
1
);
private
final
int
cmdCode
;
WsResponseEventEnum
(
int
uriCode
)
{
this
.
cmdCode
=
uriCode
;
}
public
int
getCmdCode
()
{
return
cmdCode
;
}
}
common/src/main/java/com/wecloud/im/ws/service/impl/MangerChannelServiceImpl.java
View file @
7b2511a7
...
...
@@ -32,7 +32,7 @@ public class MangerChannelServiceImpl implements MangerChannelService {
* <p>
* 由于来自远程端调用下发数据 如果是群聊1000人群则调用1000次 为不要占用太多资源 需要排队下发
* 经过并发测试 200并发1000人群消息 需要调用200x1000=20w次 考虑单机cpu性能还要顾及本机api业务 设置阻塞队列
* 为避免过多占用本地io线程导致response慢,设置LinkedBlockingQueue数量多可以避免抢占,
TODO
(队列数量需要测试调试到最优数量 )
* 为避免过多占用本地io线程导致response慢,设置LinkedBlockingQueue数量多可以避免抢占, (队列数量需要测试调试到最优数量 )
* 最大线程数量不要设置太多 数量、优先级一定要比本地io线程低级
*
*
...
...
@@ -108,8 +108,8 @@ public class MangerChannelServiceImpl implements MangerChannelService {
//
//
// /**
// *
TODO
待完成: 根据ACK回执 以及线程等待超时机制来判断客户端是否离线和超时;
// *
TODO
待完成: 发送后阻塞当前子线程2秒后获取ack回执 如客户端发起ack回执则需要主动唤醒当前子线程 立马唤醒当前子线程, 判断如果已回执则返回发送成功, 如果未回执则判断客户端是否断线或发送错误
// * 待完成: 根据ACK回执 以及线程等待超时机制来判断客户端是否离线和超时;
// * 待完成: 发送后阻塞当前子线程2秒后获取ack回执 如客户端发起ack回执则需要主动唤醒当前子线程 立马唤醒当前子线程, 判断如果已回执则返回发送成功, 如果未回执则判断客户端是否断线或发送错误
// *
// * @param msg
// * @param userId
...
...
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