-
Notifications
You must be signed in to change notification settings - Fork 223
/
KeepaliveExample.java
70 lines (60 loc) · 2.01 KB
/
KeepaliveExample.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
package io.rong.example.chatroom;
import io.rong.RongCloud;
import io.rong.methods.chatroom.keepalive.Keepalive;
import io.rong.models.chatroom.ChatroomModel;
import io.rong.models.response.ChatroomKeepaliveResult;
import io.rong.models.response.ResponseResult;
/**
*
* 聊天时保活示例
* @author RongCloud
*
* @version 3.0.0
*/
public class KeepaliveExample {
/**
* 此处替换成您的appKey
* */
private static final String appKey = "appKey";
/**
* 此处替换成您的appSecret
* */
private static final String appSecret = "appSecret";
/**
* 自定义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);
Keepalive keepalive = rongCloud.chatroom.keepalive;
/**
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
*
* 添加保活聊天室
*
**/
ChatroomModel chatroom = new ChatroomModel()
.setId("d7ec7a8b8d8546c98b0973417209a548");
ResponseResult addResult = keepalive.add(chatroom);
System.out.println("add keepalive result"+addResult.toString());
/**
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
*
* 删除保活聊天室
*
**/
ResponseResult removeResult = keepalive.remove(chatroom);
System.out.println("keepalive remove"+removeResult.toString());
/**
*
* API 文档: https://doc.rongcloud.cn/imserver/server/v1/im-server-api-list-v1
*
* 获取保活聊天室
*
**/
ChatroomKeepaliveResult result = keepalive.getList();
System.out.println("keepalive getList"+result.toString());
}
}