Skip to content

Commit 0da09a3

Browse files
committed
Revert Deprecated Classes
1 parent 6125379 commit 0da09a3

File tree

2 files changed

+228
-0
lines changed

2 files changed

+228
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
@@ -1,116 +0,0 @@
2+
package com.qiniu.rtc;
3+
4+
import com.qiniu.common.Constants;
5+
import com.qiniu.common.QiniuException;
6+
import com.qiniu.http.Client;
7+
import com.qiniu.http.Response;
8+
import com.qiniu.util.Auth;
9+
import com.qiniu.util.Json;
10+
import com.qiniu.util.StringMap;
11+
12+
@Deprecated
13+
public class RtcAppManager {
14+
15+
private final Auth auth;
16+
private final String host;
17+
private final Client client;
18+
19+
private StringMap params;
20+
21+
@Deprecated
22+
public RtcAppManager(Auth auth) {
23+
this(auth, "http://rtc.qiniuapi.com");
24+
}
25+
26+
@Deprecated
27+
public RtcAppManager(Auth auth, String host) {
28+
this.auth = auth;
29+
this.host = host;
30+
this.client = new Client();
31+
this.params = new StringMap();
32+
}
33+
34+
@Deprecated
35+
public RtcAppManager(Auth auth, String host, Client client) {
36+
this.auth = auth;
37+
this.host = host;
38+
this.client = client;
39+
this.params = new StringMap();
40+
}
41+
42+
/**
43+
* @param hub 绑定的直播 hub,可选,使用此 hub 的资源进行推流等业务功能,hub 与 app 必须属于同一个七牛账户
44+
* @param title app 的名称,可选,注意,Title 不是唯一标识,重复 create 动作将生成多个 app
45+
* @param maxUsers int 类型,可选,连麦房间支持的最大在线人数。
46+
* @param noAutoKickUser bool 类型,可选,禁止自动踢人(抢流)。默认为 false ,即同一个身份的 client (app/room/user) ,新的连
47+
* 麦请求可以成功,旧连接被关闭。
48+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
49+
* @throws QiniuException
50+
*/
51+
@Deprecated
52+
public Response createApp(String hub, String title, int maxUsers,
53+
boolean noAutoKickUser) throws QiniuException {
54+
if (hub != null) {
55+
params.put("hub", hub);
56+
}
57+
if (title != null) {
58+
params.put("title", title);
59+
}
60+
if (hub != null) {
61+
params.put("maxUsers", maxUsers);
62+
}
63+
params.put("noAutoKickUser", noAutoKickUser);
64+
65+
String url = String.format("%s%s", host, "/v3/apps");
66+
byte[] body = Json.encode(params).getBytes(Constants.UTF_8);
67+
StringMap headers = auth.authorizationV2(url, "POST", body, Client.JsonMime);
68+
return client.post(url, body, headers, Client.JsonMime);
69+
}
70+
71+
/**
72+
* @param appId 房间所属帐号的 app
73+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
74+
* @throws QiniuException
75+
*/
76+
@Deprecated
77+
public Response getApp(String appId) throws QiniuException {
78+
String url = String.format("%s%s%s", host, "/v3/apps/", appId);
79+
StringMap headers = auth.authorizationV2(url);
80+
return client.get(url, headers);
81+
}
82+
83+
/**
84+
* @param appId 房间所属帐号的 app
85+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
86+
* @throws QiniuException
87+
*/
88+
@Deprecated
89+
public Response deleteApp(String appId) throws QiniuException {
90+
String urlStr = String.format("%s%s%s", host, "/v3/apps/", appId);
91+
StringMap headers = auth.authorizationV2(urlStr, "DELETE", null, null);
92+
return client.delete(urlStr, headers);
93+
}
94+
95+
/**
96+
* @param appId 房间所属帐号的 app
97+
* @param hub 绑定的直播 hub,可选,使用此 hub 的资源进行推流等业务功能,hub 与 app 必须属于同一个七牛账户
98+
* @param title app 的名称,可选,注意,Title 不是唯一标识,重复 create 动作将生成多个 app
99+
* @param maxUsers int 类型,可选,连麦房间支持的最大在线人数。
100+
* @param noAutoKickUser bool 类型,可选,禁止自动踢人(抢流)。默认为 false ,即同一个身份的 client (app/room/user) ,新的连
101+
* 麦请求可以成功,旧连接被关闭。
102+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
103+
* @throws QiniuException
104+
*/
105+
@Deprecated
106+
public Response updateApp(String appId, String hub, String title, int maxUsers, boolean noAutoKickUser) throws
107+
QiniuException {
108+
if (hub != null) {
109+
params.put("hub", hub);
110+
}
111+
if (title != null) {
112+
params.put("title", title);
113+
}
114+
if (hub != null) {
115+
params.put("maxUsers", maxUsers);
116+
}
117+
params.put("noAutoKickUser", noAutoKickUser);
118+
119+
String url = String.format("%s%s%s", host, "/v3/apps/", appId);
120+
byte[] body = Json.encode(params).getBytes(Constants.UTF_8);
121+
StringMap headers = auth.authorizationV2(url, "POST", body, Client.JsonMime);
122+
return client.post(url, body, headers, Client.JsonMime);
123+
}
124+
125+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@@ -1,95 +0,0 @@
2+
package com.qiniu.rtc;
3+
4+
import com.google.gson.Gson;
5+
import com.qiniu.common.QiniuException;
6+
import com.qiniu.http.Client;
7+
import com.qiniu.http.Response;
8+
import com.qiniu.rtc.model.RoomAccess;
9+
import com.qiniu.util.Auth;
10+
import com.qiniu.util.StringMap;
11+
12+
@Deprecated
13+
public class RtcRoomManager {
14+
private final Auth auth;
15+
private final String host;
16+
private final Client client;
17+
private Gson gson;
18+
19+
@Deprecated
20+
public RtcRoomManager(Auth auth) {
21+
this(auth, "http://rtc.qiniuapi.com");
22+
}
23+
24+
@Deprecated
25+
public RtcRoomManager(Auth auth, String host) {
26+
this.auth = auth;
27+
this.host = host;
28+
client = new Client();
29+
gson = new Gson();
30+
}
31+
32+
/**
33+
* @param appId 房间所属帐号的 app
34+
* @param roomName 操作所查询的连麦房间
35+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
36+
* @throws QiniuException
37+
*/
38+
@Deprecated
39+
public Response listUser(String appId, String roomName) throws QiniuException {
40+
String url = getLink(appId, roomName, "users");
41+
StringMap headers = auth.authorizationV2(url);
42+
return client.get(url, headers);
43+
}
44+
45+
/**
46+
* @param appId 房间所属帐号的 app
47+
* @param roomName 操作房间名
48+
* @param userId 被踢人员
49+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
50+
* @throws QiniuException
51+
*/
52+
@Deprecated
53+
public Response kickUser(String appId, String roomName, String userId) throws QiniuException {
54+
String urlStr = getLink(appId, roomName, "users/" + userId);
55+
StringMap headers = auth.authorizationV2(urlStr, "DELETE", null, null);
56+
return client.delete(urlStr, headers);
57+
}
58+
59+
/**
60+
* @param appId 连麦房间所属的 app
61+
* @param prefix 所查询房间名的前缀索引,可以为空。
62+
* @param offset 分页查询的位移标记
63+
* @param limit 此次查询的最大长度
64+
* @return Response 如果不读取Response的数据,请注意调用Close方法关闭
65+
* @throws QiniuException
66+
*/
67+
@Deprecated
68+
public Response listActiveRooms(String appId, String prefix, int offset, int limit) throws QiniuException {
69+
String url = getLink(appId, null, "?prefix=" + prefix + "&offset=" + offset + "&limit=" + limit);
70+
StringMap headers = auth.authorizationV2(url);
71+
return client.get(url, headers);
72+
}
73+
74+
private String getLink(String appId, String roomName, String param) {
75+
StringBuilder builder = new StringBuilder();
76+
builder.append(host);
77+
builder.append("/v3/apps/").append(appId).append("/rooms");
78+
if (roomName != null) {
79+
builder.append("/").append(roomName).append("/");
80+
}
81+
builder.append(param);
82+
return builder.toString();
83+
}
84+
85+
/**
86+
* @param appId 房间所属帐号的 app
87+
* @param roomName 房间名称,需满足规格 ^[a-zA-Z0-9_-]{3,64}$
88+
* @param userId 请求加入房间的用户 ID,需满足规格 ^[a-zA-Z0-9_-]{3,50}$
89+
* @param expireAt int64 类型,鉴权的有效时间,传入以秒为单位的64位Unix绝对时间,token 将在该时间后失效
90+
* @param permission 该用户的房间管理权限,"admin" 或 "user",默认为 "user" 。当权限角色为 "admin" 时,拥有将其他用户移除出房
91+
* 间等特权.
92+
* @return roomToken
93+
* @throws Exception
94+
*/
95+
@Deprecated
96+
public String getRoomToken(String appId, String roomName, String userId,
97+
long expireAt, String permission) throws Exception {
98+
RoomAccess access = new RoomAccess(appId, roomName, userId, expireAt, permission);
99+
String json = gson.toJson(access);
100+
return auth.signRoomToken(json);
101+
}
102+
103+
}

0 commit comments

Comments
 (0)