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
+ }
0 commit comments