Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions src/main/java/com/qiniu/pili/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,37 @@ public void deleteRoom(String room) throws PiliException{
}

/**
* 暂未开放
* 查询连麦房间活跃人数
*/
// public AllActiveUsers activeUsers(String roomName) throws PiliException{
// String path = this.baseUrl + "/rooms/"+roomName+"/users";
// try {
// String resp = cli.callWithGet(path);
// AllActiveUsers us = gson.fromJson(resp, AllActiveUsers.class);
// return us;
// }catch (PiliException e){
//// e.printStackTrace();
// throw e;
// }catch (Exception e){
public AllActiveUsers activeUsers(String roomName) throws PiliException{
String path = this.baseUrl + "/rooms/"+roomName+"/users";
try {
String resp = cli.callWithGet(path);
AllActiveUsers us = gson.fromJson(resp, AllActiveUsers.class);
return us;
}catch (PiliException e){
// e.printStackTrace();
// throw new PiliException(e);
// }
// }
throw e;
}catch (Exception e){
e.printStackTrace();
throw new PiliException(e);
}
}

/**
* 暂未开放
* 剔除连麦用户
*/
// public void rejectUser(String roomName, String userId)throws PiliException{
// String path = this.baseUrl + "/rooms/"+roomName + "/users/" + userId;
// try {
// cli.callWithDelete(path);
// }catch (PiliException e){
// throw e;
// }catch (Exception e){
// e.printStackTrace();
// throw new PiliException(e);
// }
// }
public void rejectUser(String roomName, String userId)throws PiliException{
String path = this.baseUrl + "/rooms/"+roomName + "/users/" + userId;
try {
cli.callWithDelete(path);
}catch (PiliException e){
throw e;
}catch (Exception e){
e.printStackTrace();
throw new PiliException(e);
}
}

public String roomToken(String roomName, String userId, String perm, Date expireAt) throws Exception {
RoomAccess access = new RoomAccess(roomName, userId, perm, expireAt);
Expand Down Expand Up @@ -190,10 +190,8 @@ public CreateArgs(String ownerId){
}

public class ActiveUser{
@SerializedName("user_id")
@SerializedName("UserID")
public String userId;
@SerializedName("user_name")
public String userName;
}

public class AllActiveUsers{
Expand Down
50 changes: 24 additions & 26 deletions src/test/java/com/qiniu/pili/MeetingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ public void testCreateRoom(){

Meeting.Room room = meeting.getRoom(roomName);
System.out.println("roomName:"+room.name);
System.out.println("roomStatus:"+room.status);
assertEquals(roomName, room.name);
assertEquals("admin",room.ownerId);
assertEquals(Meeting.Status.NEW,room.status);
} catch (PiliException e){
e.printStackTrace();
// fail();
Expand Down Expand Up @@ -76,28 +74,28 @@ public void testRoomToken(){
}
}

// @Test
// public void testActiveUsers(){
// String roomName = "liujingbo";
// try {
// Meeting.AllActiveUsers users = meeting.activeUsers(roomName);
// System.out.println(users.users.length);
// for (int i = 0 ; i < users.users.length; i++){
// System.out.println(users.users[i].userId + " : " + users.users[i].userName);
// }
// }catch (PiliException e){
// fail();
// }
// }

// @Test
// public void testRejectUser(){
// String roomName = "liujingbo";
// String userId = "qiniu-186bf90c-f9b8-4ef5-b3b4-cba0e2b93064";
// try {
// meeting.rejectUser(roomName, userId);
// }catch (PiliException e){
// fail();
// }
// }
@Test
public void testActiveUsers(){
String roomName = "qs";
try {
Meeting.AllActiveUsers users = meeting.activeUsers(roomName);
System.out.println(users.users.length);
for (int i = 0 ; i < users.users.length; i++){
System.out.println(users.users[i].userId);
}
}catch (PiliException e){
fail();
}
}

@Test
public void testRejectUser(){
String roomName = "qs";
String userId = "qiniu-1afc2fa3-6e89-4453-8171-1e4bbf628fa2";
try {
meeting.rejectUser(roomName, userId);
}catch (PiliException e){
fail();
}
}
}