-
Notifications
You must be signed in to change notification settings - Fork 223
/
ConversationExample.java
73 lines (63 loc) · 2.39 KB
/
ConversationExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package io.rong.example.conversation;
import io.rong.RongCloud;
import io.rong.methods.conversation.Conversation;
import io.rong.models.response.ConversationNotificationResult;
import io.rong.models.response.ResponseResult;
import io.rong.models.conversation.ConversationModel;
import io.rong.util.CodeUtil;
import io.rong.util.CodeUtil.ConversationType;
/**
*
* 绘话示例
* @author RongCloud
*
* @version 3.0.0
*/
public class ConversationExample {
/**
* 此处替换成您的appKey
* */
private static final String appKey = "appKey";
/**
* 此处替换成您的appSecret
* */
private static final String appSecret = "appSercet";
/**
* 自定义api地址
* */
private static final String api = "http://api.rong-api.com";
public static void main(String[] args) throws Exception {
RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
//自定义 api 地址方式
// RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);
Conversation Conversation = rongCloud.conversation;
ConversationModel conversation = new ConversationModel()
.setType(ConversationType.PRIVATE.getName())
.setUserId("UgYzcDZSisNyYaZ83WXcEk11")
.setTargetId("2iXiqVWUAWwaKA55FuZvY31");
/**
*
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
* 设置消息免打扰
*
*/
ResponseResult muteConversationResult = Conversation.mute(conversation);
System.out.println("muteConversationResult: " + muteConversationResult.toString());
/**
*
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
* 解除消息免打扰
*
* */
ResponseResult unMuteConversationResult = Conversation.unMute(conversation);
System.out.println("unMuteConversationResult: " + unMuteConversationResult.toString());
/**
*
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
* 获取消息免打扰
*
* */
ConversationNotificationResult getMuteConversationResult = (ConversationNotificationResult)Conversation.get(conversation);
System.out.println("getMuteConversationResult: " + getMuteConversationResult.toString());
}
}