Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈永峰
im-common
Commits
8eb0d5ff
Unverified
Commit
8eb0d5ff
authored
Jul 31, 2021
by
Yang Libin
Committed by
GitHub
Jul 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(message): implement message api (#12)
parent
2bac04b8
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
838 additions
and
22 deletions
+838
-22
README.md
README.md
+7
-7
Message.java
src/main/java/com/qcloud/im/core/Message.java
+40
-6
AccountCheckRequest.java
...java/com/qcloud/im/model/request/AccountCheckRequest.java
+2
-0
AccountImportRequest.java
...ava/com/qcloud/im/model/request/AccountImportRequest.java
+2
-0
AdminMsgWithdrawRequest.java
.../com/qcloud/im/model/request/AdminMsgWithdrawRequest.java
+44
-0
AdminRoamMsgRequest.java
...java/com/qcloud/im/model/request/AdminRoamMsgRequest.java
+77
-0
AdminSetMsgReadRequest.java
...a/com/qcloud/im/model/request/AdminSetMsgReadRequest.java
+33
-0
AndroidInfo.java
src/main/java/com/qcloud/im/model/request/AndroidInfo.java
+75
-0
ApnsInfo.java
src/main/java/com/qcloud/im/model/request/ApnsInfo.java
+64
-0
BatchSendMsgRequest.java
...java/com/qcloud/im/model/request/BatchSendMsgRequest.java
+128
-0
GetC2CUnreadMsgRequest.java
...a/com/qcloud/im/model/request/GetC2CUnreadMsgRequest.java
+35
-0
ImportMsgRequest.java
...in/java/com/qcloud/im/model/request/ImportMsgRequest.java
+2
-0
KickRequest.java
src/main/java/com/qcloud/im/model/request/KickRequest.java
+2
-0
MultiAccountImportRequest.java
...om/qcloud/im/model/request/MultiAccountImportRequest.java
+2
-0
OfflinePushInfo.java
...ain/java/com/qcloud/im/model/request/OfflinePushInfo.java
+75
-0
PortraitSetRequest.java
.../java/com/qcloud/im/model/request/PortraitSetRequest.java
+2
-0
ProfileItem.java
src/main/java/com/qcloud/im/model/request/ProfileItem.java
+2
-0
QueryStateRequest.java
...n/java/com/qcloud/im/model/request/QueryStateRequest.java
+2
-0
SendMsgRequest.java
...main/java/com/qcloud/im/model/request/SendMsgRequest.java
+51
-1
AdminRoamMsgResult.java
...java/com/qcloud/im/model/response/AdminRoamMsgResult.java
+11
-0
AdminSetMsgReadResult.java
...a/com/qcloud/im/model/response/AdminSetMsgReadResult.java
+1
-1
BatchSendMsgResult.java
...java/com/qcloud/im/model/response/BatchSendMsgResult.java
+8
-0
C2CUnreadMsgNumListItem.java
...com/qcloud/im/model/response/C2CUnreadMsgNumListItem.java
+8
-0
C2CUnreadMsgNumResult.java
...a/com/qcloud/im/model/response/C2CUnreadMsgNumResult.java
+8
-1
ImportMsgResult.java
...in/java/com/qcloud/im/model/response/ImportMsgResult.java
+2
-1
MsgBodyItem.java
src/main/java/com/qcloud/im/model/response/MsgBodyItem.java
+11
-5
SendMsgResult.java
...main/java/com/qcloud/im/model/response/SendMsgResult.java
+8
-0
MessageTest.java
src/test/java/com/qcloud/im/MessageTest.java
+136
-0
No files found.
README.md
View file @
8eb0d5ff
...
...
@@ -15,13 +15,13 @@
### 2. 单聊消息
-
[
]
单发单聊消息
-
[
]
批量发单聊消息
-
[
]
导入单聊消息
-
[
]
查询单聊消息
-
[
]
撤回单聊消息
-
[
]
设置单聊消息已读
-
[
]
查询单聊未读消息计数
-
[
x
]
单发单聊消息
-
[
x
]
批量发单聊消息
-
[
x
]
导入单聊消息
-
[
x
]
查询单聊消息
-
[
x
]
撤回单聊消息
-
[
x
]
设置单聊消息已读
-
[
x
]
查询单聊未读消息计数
### 3. 全员推送
...
...
src/main/java/com/qcloud/im/core/Message.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
core
;
import
com.qcloud.im.IMClient
;
import
com.qcloud.im.model.request.ImportMsgRequest
;
import
com.qcloud.im.model.request.SendMsgRequest
;
import
com.qcloud.im.model.response.ImportMsgResult
;
import
com.qcloud.im.model.response.SendMsgResult
;
import
com.qcloud.im.model.request.*
;
import
com.qcloud.im.model.response.*
;
import
com.qcloud.im.util.HttpUtil
;
import
com.qcloud.im.util.JsonUtil
;
...
...
@@ -18,22 +16,58 @@ public class Message {
private
static
final
String
SERVICE_NAME
=
"openim"
;
private
static
final
String
SEND_MSG_COMMAND
=
"sendmsg"
;
private
static
final
String
IMPORT_MSG_COMMAND
=
"importmsg"
;
private
static
final
String
BATCH_SEND_MSG_COMMAND
=
"batchsendmsg"
;
private
static
final
String
ADMIN_GET_ROAM_MSG_COMMAND
=
"admin_getroammsg"
;
private
static
final
String
ADMIN_MSG_WITHDRAW_COMMAND
=
"admin_msgwithdraw"
;
private
static
final
String
ADMIN_SET_MSG_READ_COMMAND
=
"admin_set_msg_read"
;
private
static
final
String
GET_C2C_UNREAD_MSG_NUM_COMMAND
=
"get_c2c_unread_msg_num"
;
private
final
IMClient
imClient
;
public
Message
(
IMClient
imClient
)
{
this
.
imClient
=
imClient
;
}
public
SendMsgResult
sendMsg
(
SendMsgRequest
sendMsgRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
SEND_MSG_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
sendMsgRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
SendMsgResult
.
class
);
}
public
BatchSendMsgResult
batchSendMsg
(
BatchSendMsgRequest
batchSendMsgRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
BATCH_SEND_MSG_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
batchSendMsgRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
BatchSendMsgResult
.
class
);
}
public
ImportMsgResult
importMsg
(
ImportMsgRequest
importMsgRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
IMPORT_MSG_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
importMsgRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
ImportMsgResult
.
class
);
}
public
Message
(
IMClient
imClient
)
{
this
.
imClient
=
imClient
;
public
AdminRoamMsgResult
getRoamMsg
(
AdminRoamMsgRequest
adminRoamMsgRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
ADMIN_GET_ROAM_MSG_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
adminRoamMsgRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
AdminRoamMsgResult
.
class
);
}
public
AdminMsgWithdrawResult
msgWithdraw
(
AdminMsgWithdrawRequest
adminMsgWithdrawRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
ADMIN_MSG_WITHDRAW_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
adminMsgWithdrawRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
AdminMsgWithdrawResult
.
class
);
}
public
AdminSetMsgReadResult
setMsgRead
(
AdminSetMsgReadRequest
adminSetMsgReadRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
ADMIN_SET_MSG_READ_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
adminSetMsgReadRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
AdminSetMsgReadResult
.
class
);
}
public
C2CUnreadMsgNumResult
getC2CUnreadMsgNum
(
GetC2CUnreadMsgRequest
getC2CUnreadMsgRequest
)
throws
IOException
{
String
url
=
imClient
.
getUrl
(
SERVICE_NAME
,
GET_C2C_UNREAD_MSG_NUM_COMMAND
);
String
result
=
HttpUtil
.
post
(
url
,
JsonUtil
.
obj2Str
(
getC2CUnreadMsgRequest
),
null
);
return
JsonUtil
.
str2Obj
(
result
,
C2CUnreadMsgNumResult
.
class
);
}
}
src/main/java/com/qcloud/im/model/request/AccountCheckRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
...
...
@@ -8,6 +9,7 @@ import java.util.List;
* @author bingo
* @since 2021/7/30 17:26
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AccountCheckRequest
extends
GenericRequest
{
@JsonProperty
(
"CheckItem"
)
private
List
<
AccountCheckItem
>
checkItemList
;
...
...
src/main/java/com/qcloud/im/model/request/AccountImportRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author hyh
* @since 2021/07/29 14:56
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AccountImportRequest
extends
GenericRequest
{
@JsonProperty
(
"Identifier"
)
private
String
identifier
;
...
...
src/main/java/com/qcloud/im/model/request/AdminMsgWithdrawRequest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 14:43
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AdminMsgWithdrawRequest
extends
GenericRequest
{
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
@JsonProperty
(
"MsgKey"
)
private
String
msgKey
;
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
String
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
String
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
String
getMsgKey
()
{
return
msgKey
;
}
public
void
setMsgKey
(
String
msgKey
)
{
this
.
msgKey
=
msgKey
;
}
}
src/main/java/com/qcloud/im/model/request/AdminRoamMsgRequest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 14:27
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AdminRoamMsgRequest
extends
GenericRequest
{
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
@JsonProperty
(
"MaxCnt"
)
private
Integer
maxCnt
;
@JsonProperty
(
"MinTime"
)
private
Integer
minTime
;
@JsonProperty
(
"MaxTime"
)
private
Integer
maxTime
;
@JsonProperty
(
"LastMsgKey"
)
private
String
lastMsgKey
;
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
String
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
String
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
Integer
getMaxCnt
()
{
return
maxCnt
;
}
public
void
setMaxCnt
(
Integer
maxCnt
)
{
this
.
maxCnt
=
maxCnt
;
}
public
Integer
getMinTime
()
{
return
minTime
;
}
public
void
setMinTime
(
Integer
minTime
)
{
this
.
minTime
=
minTime
;
}
public
Integer
getMaxTime
()
{
return
maxTime
;
}
public
void
setMaxTime
(
Integer
maxTime
)
{
this
.
maxTime
=
maxTime
;
}
public
String
getLastMsgKey
()
{
return
lastMsgKey
;
}
public
void
setLastMsgKey
(
String
lastMsgKey
)
{
this
.
lastMsgKey
=
lastMsgKey
;
}
}
src/main/java/com/qcloud/im/model/request/AdminSetMsgReadRequest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 15:29
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AdminSetMsgReadRequest
extends
GenericRequest
{
@JsonProperty
(
"Report_Account"
)
private
String
reportAccount
;
@JsonProperty
(
"Peer_Account"
)
private
String
peerAccount
;
public
String
getReportAccount
()
{
return
reportAccount
;
}
public
void
setReportAccount
(
String
reportAccount
)
{
this
.
reportAccount
=
reportAccount
;
}
public
String
getPeerAccount
()
{
return
peerAccount
;
}
public
void
setPeerAccount
(
String
peerAccount
)
{
this
.
peerAccount
=
peerAccount
;
}
}
src/main/java/com/qcloud/im/model/request/AndroidInfo.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 10:55
*/
public
class
AndroidInfo
{
@JsonProperty
(
"Sound"
)
private
String
sound
;
@JsonProperty
(
"HuaWeiChannelID"
)
private
String
huaweiChannelId
;
@JsonProperty
(
"XiaoMiChannelID"
)
private
String
xiaomiChannelId
;
@JsonProperty
(
"OPPOChannelID"
)
private
String
oppoChannelId
;
@JsonProperty
(
"OPPOChannelID"
)
private
String
googleChannelId
;
@JsonProperty
(
"VIVOClassification"
)
private
String
vivoChannelId
;
public
String
getSound
()
{
return
sound
;
}
public
void
setSound
(
String
sound
)
{
this
.
sound
=
sound
;
}
public
String
getHuaweiChannelId
()
{
return
huaweiChannelId
;
}
public
void
setHuaweiChannelId
(
String
huaweiChannelId
)
{
this
.
huaweiChannelId
=
huaweiChannelId
;
}
public
String
getXiaomiChannelId
()
{
return
xiaomiChannelId
;
}
public
void
setXiaomiChannelId
(
String
xiaomiChannelId
)
{
this
.
xiaomiChannelId
=
xiaomiChannelId
;
}
public
String
getOppoChannelId
()
{
return
oppoChannelId
;
}
public
void
setOppoChannelId
(
String
oppoChannelId
)
{
this
.
oppoChannelId
=
oppoChannelId
;
}
public
String
getGoogleChannelId
()
{
return
googleChannelId
;
}
public
void
setGoogleChannelId
(
String
googleChannelId
)
{
this
.
googleChannelId
=
googleChannelId
;
}
public
String
getVivoChannelId
()
{
return
vivoChannelId
;
}
public
void
setVivoChannelId
(
String
vivoChannelId
)
{
this
.
vivoChannelId
=
vivoChannelId
;
}
}
src/main/java/com/qcloud/im/model/request/ApnsInfo.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 11:03
*/
public
class
ApnsInfo
{
@JsonProperty
(
"BadgeMode"
)
private
String
badgeMode
;
@JsonProperty
(
"Title"
)
private
String
title
;
@JsonProperty
(
"SubTitle"
)
private
String
subTitle
;
@JsonProperty
(
"Image"
)
private
String
image
;
@JsonProperty
(
"MutableContent"
)
private
Integer
mutableContent
;
public
String
getBadgeMode
()
{
return
badgeMode
;
}
public
void
setBadgeMode
(
String
badgeMode
)
{
this
.
badgeMode
=
badgeMode
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getSubTitle
()
{
return
subTitle
;
}
public
void
setSubTitle
(
String
subTitle
)
{
this
.
subTitle
=
subTitle
;
}
public
String
getImage
()
{
return
image
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
public
Integer
getMutableContent
()
{
return
mutableContent
;
}
public
void
setMutableContent
(
Integer
mutableContent
)
{
this
.
mutableContent
=
mutableContent
;
}
}
src/main/java/com/qcloud/im/model/request/BatchSendMsgRequest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.qcloud.im.model.response.MsgBodyItem
;
import
java.util.List
;
/**
* @author bingo
* @since 2021/7/31 11:09
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
BatchSendMsgRequest
{
@JsonProperty
(
"SyncOtherMachine"
)
private
Integer
syncOtherMachine
;
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"To_Account"
)
private
List
<
String
>
toAccount
;
@JsonProperty
(
"MsgSeq"
)
private
Integer
msgSeq
;
@JsonProperty
(
"MsgRandom"
)
private
Integer
msgRandom
;
@JsonProperty
(
"MsgBody"
)
private
List
<
MsgBodyItem
>
msgBody
;
@JsonProperty
(
"CloudCustomData"
)
private
String
cloudCustomData
;
@JsonProperty
(
"SendMsgControl"
)
private
List
<
String
>
sendMsgControl
;
@JsonProperty
(
"OfflinePushInfo"
)
private
OfflinePushInfo
offlinePushInfo
;
public
BatchSendMsgRequest
()
{
}
public
BatchSendMsgRequest
(
Integer
syncOtherMachine
,
String
fromAccount
,
List
<
String
>
toAccount
,
Integer
msgSeq
,
Integer
msgRandom
,
List
<
MsgBodyItem
>
msgBody
,
String
cloudCustomData
,
List
<
String
>
sendMsgControl
,
OfflinePushInfo
offlinePushInfo
)
{
this
.
syncOtherMachine
=
syncOtherMachine
;
this
.
fromAccount
=
fromAccount
;
this
.
toAccount
=
toAccount
;
this
.
msgSeq
=
msgSeq
;
this
.
msgRandom
=
msgRandom
;
this
.
msgBody
=
msgBody
;
this
.
cloudCustomData
=
cloudCustomData
;
this
.
sendMsgControl
=
sendMsgControl
;
this
.
offlinePushInfo
=
offlinePushInfo
;
}
public
Integer
getSyncOtherMachine
()
{
return
syncOtherMachine
;
}
public
void
setSyncOtherMachine
(
Integer
syncOtherMachine
)
{
this
.
syncOtherMachine
=
syncOtherMachine
;
}
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
List
<
String
>
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
List
<
String
>
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
Integer
getMsgSeq
()
{
return
msgSeq
;
}
public
void
setMsgSeq
(
Integer
msgSeq
)
{
this
.
msgSeq
=
msgSeq
;
}
public
Integer
getMsgRandom
()
{
return
msgRandom
;
}
public
void
setMsgRandom
(
Integer
msgRandom
)
{
this
.
msgRandom
=
msgRandom
;
}
public
List
<
MsgBodyItem
>
getMsgBody
()
{
return
msgBody
;
}
public
void
setMsgBody
(
List
<
MsgBodyItem
>
msgBody
)
{
this
.
msgBody
=
msgBody
;
}
public
String
getCloudCustomData
()
{
return
cloudCustomData
;
}
public
void
setCloudCustomData
(
String
cloudCustomData
)
{
this
.
cloudCustomData
=
cloudCustomData
;
}
public
List
<
String
>
getSendMsgControl
()
{
return
sendMsgControl
;
}
public
void
setSendMsgControl
(
List
<
String
>
sendMsgControl
)
{
this
.
sendMsgControl
=
sendMsgControl
;
}
public
OfflinePushInfo
getOfflinePushInfo
()
{
return
offlinePushInfo
;
}
public
void
setOfflinePushInfo
(
OfflinePushInfo
offlinePushInfo
)
{
this
.
offlinePushInfo
=
offlinePushInfo
;
}
}
src/main/java/com/qcloud/im/model/request/GetC2CUnreadMsgRequest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
/**
* @author bingo
* @since 2021/7/31 15:37
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
GetC2CUnreadMsgRequest
extends
GenericRequest
{
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
@JsonProperty
(
"Peer_Account"
)
private
List
<
String
>
peerAccount
;
public
String
getToAccount
()
{
return
toAccount
;
}
public
void
setToAccount
(
String
toAccount
)
{
this
.
toAccount
=
toAccount
;
}
public
List
<
String
>
getPeerAccount
()
{
return
peerAccount
;
}
public
void
setPeerAccount
(
List
<
String
>
peerAccount
)
{
this
.
peerAccount
=
peerAccount
;
}
}
src/main/java/com/qcloud/im/model/request/ImportMsgRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.qcloud.im.model.response.MsgBodyItem
;
...
...
@@ -9,6 +10,7 @@ import java.util.List;
* @author hyh
* @since 2021/07/29 14:25
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ImportMsgRequest
extends
GenericRequest
{
@JsonProperty
(
"SyncFromOldSystem"
)
private
Integer
syncFromOldSystem
;
...
...
src/main/java/com/qcloud/im/model/request/KickRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/30 17:31
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
KickRequest
extends
GenericRequest
{
@JsonProperty
(
"Identifier"
)
private
String
identifier
;
...
...
src/main/java/com/qcloud/im/model/request/MultiAccountImportRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
...
...
@@ -8,6 +9,7 @@ import java.util.List;
* @author bingo
* @since 2021/7/30 17:07
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
MultiAccountImportRequest
extends
GenericRequest
{
@JsonProperty
(
"Accounts"
)
private
List
<
String
>
accounts
;
...
...
src/main/java/com/qcloud/im/model/request/OfflinePushInfo.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author bingo
* @since 2021/7/31 10:52
*/
public
class
OfflinePushInfo
{
@JsonProperty
(
"PushFlag"
)
private
Integer
pushFlag
;
@JsonProperty
(
"Title"
)
private
String
title
;
@JsonProperty
(
"Desc"
)
private
String
desc
;
@JsonProperty
(
"Ext"
)
private
String
ext
;
@JsonProperty
(
"AndroidInfo"
)
private
AndroidInfo
androidInfo
;
@JsonProperty
(
"ApnsInfo"
)
private
ApnsInfo
apnsInfo
;
public
Integer
getPushFlag
()
{
return
pushFlag
;
}
public
void
setPushFlag
(
Integer
pushFlag
)
{
this
.
pushFlag
=
pushFlag
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
public
String
getExt
()
{
return
ext
;
}
public
void
setExt
(
String
ext
)
{
this
.
ext
=
ext
;
}
public
AndroidInfo
getAndroidInfo
()
{
return
androidInfo
;
}
public
void
setAndroidInfo
(
AndroidInfo
androidInfo
)
{
this
.
androidInfo
=
androidInfo
;
}
public
ApnsInfo
getApnsInfo
()
{
return
apnsInfo
;
}
public
void
setApnsInfo
(
ApnsInfo
apnsInfo
)
{
this
.
apnsInfo
=
apnsInfo
;
}
}
src/main/java/com/qcloud/im/model/request/PortraitSetRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
...
...
@@ -8,6 +9,7 @@ import java.util.List;
* @author hyh
* @since 2021/07/29 15:01
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
PortraitSetRequest
extends
GenericRequest
{
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
...
...
src/main/java/com/qcloud/im/model/request/ProfileItem.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
/**
* @author hyh
* @since 2021/07/29 15:06
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
ProfileItem
{
@JsonProperty
(
"Tag"
)
private
String
tag
;
...
...
src/main/java/com/qcloud/im/model/request/QueryStateRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
...
...
@@ -8,6 +9,7 @@ import java.util.List;
* @author bingo
* @since 2021/7/30 17:35
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
QueryStateRequest
extends
GenericRequest
{
@JsonProperty
(
"IsNeedDetail"
)
private
Integer
isNeedDetail
;
...
...
src/main/java/com/qcloud/im/model/request/SendMsgRequest.java
View file @
8eb0d5ff
package
com
.
qcloud
.
im
.
model
.
request
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.qcloud.im.model.response.MsgBodyItem
;
...
...
@@ -9,10 +10,14 @@ import java.util.List;
* @author hyh
* @since 2021/07/29 11:31
*/
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
SendMsgRequest
extends
GenericRequest
{
@JsonProperty
(
"SyncOtherMachine"
)
private
Integer
syncOtherMachine
;
@JsonProperty
(
"From_Account"
)
private
String
fromAccount
;
@JsonProperty
(
"To_Account"
)
private
String
toAccount
;
...
...
@@ -28,24 +33,37 @@ public class SendMsgRequest extends GenericRequest {
@JsonProperty
(
"MsgTimeStamp"
)
private
Integer
msgTimeStamp
;
@JsonProperty
(
"ForbidCallbackControl"
)
private
List
<
String
>
forbidCallbackControl
;
@JsonProperty
(
"SendMsgControl"
)
private
List
<
String
>
sendMsgControl
;
@JsonProperty
(
"MsgBody"
)
private
List
<
MsgBodyItem
>
msgBody
;
@JsonProperty
(
"CloudCustomData"
)
private
String
cloudCustomData
;
@JsonProperty
(
"OfflinePushInfo"
)
private
OfflinePushInfo
offlinePushInfo
;
public
SendMsgRequest
()
{
}
public
SendMsgRequest
(
Integer
syncOtherMachine
,
String
toAccount
,
Integer
msgLifeTime
,
Integer
msgSeq
,
Integer
msgRandom
,
Integer
msgTimeStamp
,
List
<
MsgBodyItem
>
msgBody
,
String
cloudCustomData
)
{
public
SendMsgRequest
(
Integer
syncOtherMachine
,
String
fromAccount
,
String
toAccount
,
Integer
msgLifeTime
,
Integer
msgSeq
,
Integer
msgRandom
,
Integer
msgTimeStamp
,
List
<
String
>
forbidCallbackControl
,
List
<
String
>
sendMsgControl
,
List
<
MsgBodyItem
>
msgBody
,
String
cloudCustomData
,
OfflinePushInfo
offlinePushInfo
)
{
this
.
syncOtherMachine
=
syncOtherMachine
;
this
.
fromAccount
=
fromAccount
;
this
.
toAccount
=
toAccount
;
this
.
msgLifeTime
=
msgLifeTime
;
this
.
msgSeq
=
msgSeq
;
this
.
msgRandom
=
msgRandom
;
this
.
msgTimeStamp
=
msgTimeStamp
;
this
.
forbidCallbackControl
=
forbidCallbackControl
;
this
.
sendMsgControl
=
sendMsgControl
;
this
.
msgBody
=
msgBody
;
this
.
cloudCustomData
=
cloudCustomData
;
this
.
offlinePushInfo
=
offlinePushInfo
;
}
public
Integer
getSyncOtherMachine
()
{
...
...
@@ -56,6 +74,14 @@ public class SendMsgRequest extends GenericRequest {
this
.
syncOtherMachine
=
syncOtherMachine
;
}
public
String
getFromAccount
()
{
return
fromAccount
;
}
public
void
setFromAccount
(
String
fromAccount
)
{
this
.
fromAccount
=
fromAccount
;
}
public
String
getToAccount
()
{
return
toAccount
;
}
...
...
@@ -96,6 +122,22 @@ public class SendMsgRequest extends GenericRequest {
this
.
msgTimeStamp
=
msgTimeStamp
;
}
public
List
<
String
>
getForbidCallbackControl
()
{
return
forbidCallbackControl
;
}
public
void
setForbidCallbackControl
(
List
<
String
>
forbidCallbackControl
)
{
this
.
forbidCallbackControl
=
forbidCallbackControl
;
}
public
List
<
String
>
getSendMsgControl
()
{
return
sendMsgControl
;
}
public
void
setSendMsgControl
(
List
<
String
>
sendMsgControl
)
{
this
.
sendMsgControl
=
sendMsgControl
;
}
public
List
<
MsgBodyItem
>
getMsgBody
()
{
return
msgBody
;
}
...
...
@@ -111,4 +153,12 @@ public class SendMsgRequest extends GenericRequest {
public
void
setCloudCustomData
(
String
cloudCustomData
)
{
this
.
cloudCustomData
=
cloudCustomData
;
}
public
OfflinePushInfo
getOfflinePushInfo
()
{
return
offlinePushInfo
;
}
public
void
setOfflinePushInfo
(
OfflinePushInfo
offlinePushInfo
)
{
this
.
offlinePushInfo
=
offlinePushInfo
;
}
}
src/main/java/com/qcloud/im/model/response/AdminRoamMsgResult.java
View file @
8eb0d5ff
...
...
@@ -63,4 +63,15 @@ public class AdminRoamMsgResult extends GenericResult {
public
void
setMsgList
(
List
<
MsgListItem
>
msgList
)
{
this
.
msgList
=
msgList
;
}
@Override
public
String
toString
()
{
return
"AdminRoamMsgResult{"
+
"complete="
+
complete
+
", msgCnt="
+
msgCnt
+
", lastMsgTime="
+
lastMsgTime
+
", lastMsgKey="
+
lastMsgKey
+
", msgList="
+
msgList
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/AdminSetMsgRead.java
→
src/main/java/com/qcloud/im/model/response/AdminSetMsgRead
Result
.java
View file @
8eb0d5ff
...
...
@@ -4,5 +4,5 @@ package com.qcloud.im.model.response;
* @author hyh
* @since 2021/07/28 20:32
*/
public
class
AdminSetMsgRead
extends
GenericResult
{
public
class
AdminSetMsgRead
Result
extends
GenericResult
{
}
src/main/java/com/qcloud/im/model/response/BatchSendMsgResult.java
View file @
8eb0d5ff
...
...
@@ -30,4 +30,12 @@ public class BatchSendMsgResult extends GenericResult {
public
void
setErrorList
(
List
<
BatchSendMsgErrorItem
>
errorList
)
{
this
.
errorList
=
errorList
;
}
@Override
public
String
toString
()
{
return
"BatchSendMsgResult{"
+
"msgKey='"
+
msgKey
+
'\''
+
", errorList="
+
errorList
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/C2CUnreadMsgNumListItem.java
View file @
8eb0d5ff
...
...
@@ -28,4 +28,12 @@ public class C2CUnreadMsgNumListItem {
public
void
setUnreadMsgNum
(
String
unreadMsgNum
)
{
this
.
unreadMsgNum
=
unreadMsgNum
;
}
@Override
public
String
toString
()
{
return
"C2CUnreadMsgNumListItem{"
+
"peerAccount='"
+
peerAccount
+
'\''
+
", unreadMsgNum='"
+
unreadMsgNum
+
'\''
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/C2CUnreadMsgNum.java
→
src/main/java/com/qcloud/im/model/response/C2CUnreadMsgNum
Result
.java
View file @
8eb0d5ff
...
...
@@ -8,7 +8,7 @@ import java.util.List;
* @author hyh
* @since 2021/07/28 20:34
*/
public
class
C2CUnreadMsgNum
extends
GenericResult
{
public
class
C2CUnreadMsgNum
Result
extends
GenericResult
{
@JsonProperty
(
"C2CUnreadMsgNumList"
)
private
List
<
C2CUnreadMsgNumListItem
>
unreadMsgNumList
;
...
...
@@ -19,4 +19,11 @@ public class C2CUnreadMsgNum extends GenericResult {
public
void
setUnreadMsgNumList
(
List
<
C2CUnreadMsgNumListItem
>
unreadMsgNumList
)
{
this
.
unreadMsgNumList
=
unreadMsgNumList
;
}
@Override
public
String
toString
()
{
return
"C2CUnreadMsgNumResult{"
+
"unreadMsgNumList="
+
unreadMsgNumList
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/ImportMsgResult.java
View file @
8eb0d5ff
...
...
@@ -4,5 +4,6 @@ package com.qcloud.im.model.response;
* @author hyh
* @since 2021/07/28 17:54
*/
public
class
ImportMsgResult
extends
GenericResult
{
public
class
ImportMsgResult
extends
GenericResult
{
}
src/main/java/com/qcloud/im/model/response/MsgBodyItem.java
View file @
8eb0d5ff
...
...
@@ -2,8 +2,6 @@ package com.qcloud.im.model.response;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
/**
* @author hyh
* @since 2021/07/28 20:42
...
...
@@ -13,7 +11,7 @@ public class MsgBodyItem {
private
String
msgType
;
@JsonProperty
(
"MsgContent"
)
private
List
<
MsgContentItem
>
msgContent
;
private
MsgContentItem
msgContent
;
public
String
getMsgType
()
{
return
msgType
;
...
...
@@ -23,11 +21,19 @@ public class MsgBodyItem {
this
.
msgType
=
msgType
;
}
public
List
<
MsgContentItem
>
getMsgContent
()
{
public
MsgContentItem
getMsgContent
()
{
return
msgContent
;
}
public
void
setMsgContent
(
List
<
MsgContentItem
>
msgContent
)
{
public
void
setMsgContent
(
MsgContentItem
msgContent
)
{
this
.
msgContent
=
msgContent
;
}
@Override
public
String
toString
()
{
return
"MsgBodyItem{"
+
"msgType='"
+
msgType
+
'\''
+
", msgContent="
+
msgContent
+
'}'
;
}
}
src/main/java/com/qcloud/im/model/response/SendMsgResult.java
View file @
8eb0d5ff
...
...
@@ -28,4 +28,12 @@ public class SendMsgResult extends GenericResult {
public
void
setMsgKey
(
String
msgKey
)
{
this
.
msgKey
=
msgKey
;
}
@Override
public
String
toString
()
{
return
"SendMsgResult{"
+
"msgTime="
+
msgTime
+
", msgKey='"
+
msgKey
+
'\''
+
'}'
;
}
}
src/test/java/com/qcloud/im/MessageTest.java
0 → 100644
View file @
8eb0d5ff
package
com
.
qcloud
.
im
;
import
com.qcloud.im.model.request.*
;
import
com.qcloud.im.model.response.*
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Properties
;
/**
* @author bingo
* @since 2021/7/31 10:37
*/
public
class
MessageTest
{
private
static
final
Properties
properties
=
new
Properties
();
private
static
final
IMClient
client
;
static
{
InputStream
resourceAsStream
=
AccountTest
.
class
.
getClassLoader
().
getResourceAsStream
(
"app.properties"
);
try
{
properties
.
load
(
resourceAsStream
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
key
=
properties
.
getProperty
(
"key"
);
String
identifier
=
properties
.
getProperty
(
"identifier"
);
Long
appId
=
Long
.
parseLong
(
properties
.
getProperty
(
"appId"
));
client
=
IMClient
.
getInstance
(
appId
,
identifier
,
key
);
}
@Test
public
void
testSendMsg
()
throws
IOException
{
SendMsgRequest
request
=
new
SendMsgRequest
();
request
.
setFromAccount
(
"test1"
);
request
.
setToAccount
(
"test2"
);
request
.
setSyncOtherMachine
(
1
);
request
.
setMsgRandom
(
123
);
request
.
setMsgTimeStamp
(
1557387418
);
request
.
setMsgLifeTime
(
604800
);
MsgBodyItem
item
=
new
MsgBodyItem
();
item
.
setMsgType
(
"TIMTextElem"
);
MsgContentItem
contentItem
=
new
MsgContentItem
();
contentItem
.
setText
(
"hello world"
);
item
.
setMsgContent
(
contentItem
);
request
.
setMsgBody
(
Collections
.
singletonList
(
item
));
SendMsgResult
result
=
client
.
message
.
sendMsg
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testBatchSendMsg
()
throws
IOException
{
BatchSendMsgRequest
request
=
new
BatchSendMsgRequest
();
request
.
setSyncOtherMachine
(
2
);
request
.
setToAccount
(
Arrays
.
asList
(
"test1"
,
"test2"
));
request
.
setMsgSeq
(
28460
);
request
.
setMsgRandom
(
1992121
);
MsgBodyItem
item
=
new
MsgBodyItem
();
item
.
setMsgType
(
"TIMTextElem"
);
MsgContentItem
contentItem
=
new
MsgContentItem
();
contentItem
.
setText
(
"hi bingo"
);
item
.
setMsgContent
(
contentItem
);
request
.
setMsgBody
(
Collections
.
singletonList
(
item
));
BatchSendMsgResult
result
=
client
.
message
.
batchSendMsg
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testImportMsg
()
throws
IOException
{
ImportMsgRequest
request
=
new
ImportMsgRequest
();
request
.
setSyncFromOldSystem
(
1
);
request
.
setFromAccount
(
"bingo"
);
request
.
setToAccount
(
"test1"
);
request
.
setMsgSeq
(
123
);
request
.
setMsgRandom
(
122
);
request
.
setMsgTimeStamp
(
1557387418
);
MsgBodyItem
item
=
new
MsgBodyItem
();
item
.
setMsgType
(
"TIMTextElem"
);
MsgContentItem
contentItem
=
new
MsgContentItem
();
contentItem
.
setText
(
"hello bingo"
);
item
.
setMsgContent
(
contentItem
);
request
.
setMsgBody
(
Collections
.
singletonList
(
item
));
ImportMsgResult
result
=
client
.
message
.
importMsg
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testAdminGetRoamMsg
()
throws
IOException
{
AdminRoamMsgRequest
request
=
new
AdminRoamMsgRequest
();
request
.
setFromAccount
(
"test1"
);
request
.
setToAccount
(
"test2"
);
request
.
setMaxCnt
(
123
);
request
.
setMinTime
(
1584669600
);
request
.
setMaxTime
(
1584673200
);
AdminRoamMsgResult
result
=
client
.
message
.
getRoamMsg
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testAdminMsgWithdraw
()
throws
IOException
{
AdminMsgWithdrawRequest
request
=
new
AdminMsgWithdrawRequest
();
request
.
setFromAccount
(
"test1"
);
request
.
setMsgKey
(
"31906_833502_1572869830"
);
request
.
setToAccount
(
"bingo"
);
AdminMsgWithdrawResult
result
=
client
.
message
.
msgWithdraw
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testAdminSetMsgRead
()
throws
IOException
{
AdminSetMsgReadRequest
request
=
new
AdminSetMsgReadRequest
();
request
.
setPeerAccount
(
"test1"
);
request
.
setReportAccount
(
"test2"
);
AdminSetMsgReadResult
result
=
client
.
message
.
setMsgRead
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
@Test
public
void
testGetC2CUnreadMsgNum
()
throws
IOException
{
GetC2CUnreadMsgRequest
request
=
new
GetC2CUnreadMsgRequest
();
request
.
setPeerAccount
(
Arrays
.
asList
(
"test1"
,
"bingo"
));
request
.
setToAccount
(
"test2"
);
C2CUnreadMsgNumResult
result
=
client
.
message
.
getC2CUnreadMsgNum
(
request
);
System
.
out
.
println
(
result
);
Assert
.
assertEquals
(
"OK"
,
result
.
getActionStatus
());
}
}
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