同步会议API

This commit is contained in:
imhao183
2021-06-01 08:45:00 +08:00
parent 0aba453a24
commit b61d292fb5
22 changed files with 270 additions and 5 deletions
@@ -70,6 +70,11 @@ public interface APIPath {
String Get_System_Setting = "/admin/system/get_setting";
String Put_System_Setting = "/admin/system/put_setting";
String Conference_List = "/admin/conference/list";
String Conference_List_Participant = "/admin/conference/list_participant";
String Conference_Create = "/admin/conference/create";
String Conference_Destroy = "/admin/conference/destroy";
String Channel_User_Info = "/channel/user_info";
String Channel_Update_Profile = "/channel/update_profile";
String Channel_Get_Profile = "/channel/get_profile";
@@ -38,6 +38,7 @@ public enum ErrorCode {
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
ERROR_CODE_NOT_LICENSED(22, "not licensed"),
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
ERROR_CODE_RECALL_TIME_EXPIRED(24, "time expired"),
@@ -50,7 +51,7 @@ public enum ErrorCode {
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
ERROR_CODE_AUTH_FAILURE(244, "auth failure"),
ERROR_CODE_CLIENT_COUNT_OUT_OF_LIMIT(245, "client count out of limit"),
ERROR_CODE_IN_BLACK_LIST(246, "user in balck list"),
ERROR_CODE_IN_BLACK_LIST(246, "user in black list"),
ERROR_CODE_FORBIDDEN_SEND_MSG(247, "forbidden send msg globally"),
ERROR_CODE_NOT_RIGHT(248, "no right to operate"),
ERROR_CODE_TIMEOUT(249, "timeout"),
@@ -0,0 +1,13 @@
package cn.wildfirechat.pojos;
public class ConferenceCreateEvent {
public String userId;
public String roomId;
public String serverId;
public String description;
public String pin;
public int max_publishers;
public int bitrate;
public boolean advance;
public boolean recording;
}
@@ -0,0 +1,6 @@
package cn.wildfirechat.pojos;
public class ConferenceDestroyEvent {
public String userId;
public String roomId;
}
@@ -0,0 +1,5 @@
package cn.wildfirechat.pojos;
public class ConferenceJoinEvent {
public String userId;
}
@@ -0,0 +1,5 @@
package cn.wildfirechat.pojos;
public class ConferenceLeaveEvent {
public String userId;
}
@@ -0,0 +1,6 @@
package cn.wildfirechat.pojos;
public class ConferencePublishEvent {
public String userId;
public boolean video;
}
@@ -0,0 +1,5 @@
package cn.wildfirechat.pojos;
public class ConferenceUnpublishEvent {
public String userId;
}
@@ -27,6 +27,8 @@ public class InputDismissGroup extends InputGroupBase {
}
public boolean isValide() {
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
return false;
return true;
}
@@ -35,6 +35,8 @@ public class InputKickoffGroupMember extends InputGroupBase {
}
public boolean isValide() {
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator) || members == null || members.isEmpty())
return false;
return true;
}
@@ -22,7 +22,9 @@ public class InputModifyGroupInfo extends InputGroupBase {
private String value;
public boolean isValide() {
return !StringUtil.isNullOrEmpty(group_id);
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
return false;
return true;
}
public String getGroup_id() {
return group_id;
@@ -10,6 +10,7 @@ package cn.wildfirechat.pojos;
import cn.wildfirechat.proto.WFCMessage;
import io.netty.util.internal.StringUtil;
import java.util.List;
@@ -25,6 +26,8 @@ public class InputQuitGroup extends InputGroupBase {
}
public boolean isValide() {
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
return false;
return true;
}
@@ -18,6 +18,8 @@ public class InputTransferGroup extends InputGroupBase {
public boolean isValide() {
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator) || StringUtil.isNullOrEmpty(new_owner))
return false;
return true;
}
@@ -0,0 +1,21 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class InputVerifyApplicationUser {
private String token;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
@@ -0,0 +1,21 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
public class OutputVerifyApplicationUser {
private String userId;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
@@ -0,0 +1,11 @@
package cn.wildfirechat.pojos;
public class PojoConferenceCreate {
public String roomId;
public String description;
public String pin;
public int max_publishers;
public int bitrate;
public boolean advance;
public boolean recording;
}
@@ -0,0 +1,12 @@
package cn.wildfirechat.pojos;
public class PojoConferenceInfo {
public String roomId;
public String serverId;
public String description;
public int max_publishers;
public int num_publishers;
public int bitrate;
public boolean advance;
public boolean recording;
}
@@ -0,0 +1,21 @@
package cn.wildfirechat.pojos;
import java.util.ArrayList;
import java.util.List;
public class PojoConferenceInfoList {
public PojoConferenceInfoList(List<PojoConferenceInfo> conferenceInfoList) {
this.conferenceInfoList = conferenceInfoList;
}
public PojoConferenceInfoList() {
conferenceInfoList = new ArrayList<>();
}
public List<PojoConferenceInfo> conferenceInfoList;
public void addConferenceInfo(PojoConferenceInfo conferenceInfo) {
this.conferenceInfoList.add(conferenceInfo);
}
}
@@ -0,0 +1,6 @@
package cn.wildfirechat.pojos;
public class PojoConferenceParticipant {
public String userId;
public boolean publishing;
}
@@ -0,0 +1,21 @@
package cn.wildfirechat.pojos;
import java.util.ArrayList;
import java.util.List;
public class PojoConferenceParticipantList {
public PojoConferenceParticipantList(List<PojoConferenceParticipant> participantList) {
this.participantList = participantList;
}
public PojoConferenceParticipantList() {
participantList = new ArrayList<>();
}
public List<PojoConferenceParticipant> participantList;
public void addConferenceInfo(PojoConferenceParticipant participant) {
this.participantList.add(participant);
}
}
@@ -0,0 +1,36 @@
package cn.wildfirechat.sdk;
import cn.wildfirechat.common.APIPath;
import cn.wildfirechat.pojos.*;
import cn.wildfirechat.sdk.model.IMResult;
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
public class ConferenceAdmin {
public static IMResult<PojoConferenceInfoList> listConferences() throws Exception {
String path = APIPath.Conference_List;
return AdminHttpUtils.httpJsonPost(path, null, PojoConferenceInfoList.class);
}
public static IMResult<PojoConferenceParticipantList> listParticipants(String roomId) throws Exception {
String path = APIPath.Conference_List_Participant;
return AdminHttpUtils.httpJsonPost(path, roomId, PojoConferenceParticipantList.class);
}
public static IMResult<Void> createRoom(String roomId, String description, String pin, int maxPublisher, boolean advance, int bitrate, boolean recording) throws Exception {
String path = APIPath.Conference_Create;
PojoConferenceCreate create = new PojoConferenceCreate();
create.roomId = roomId;
create.description = description;
create.pin = pin;
create.max_publishers = maxPublisher;
create.advance = advance;
create.bitrate = bitrate;
create.recording = recording;
return AdminHttpUtils.httpJsonPost(path, create, Void.class);
}
public static IMResult<Void> destroy(String roomId) throws Exception {
String path = APIPath.Conference_Destroy;
return AdminHttpUtils.httpJsonPost(path, roomId, Void.class);
}
}
@@ -43,9 +43,9 @@ public class Main {
testSensitiveApi();
if (commercialServer) {
testDevice();
testConference();
}
System.out.println("Congratulation, all admin test case passed!!!!!!!");
}
@@ -133,7 +133,6 @@ public class Main {
System.out.println("get user info by userId failure");
System.exit(-1);
}
InputOutputUserInfo updateUserInfo = new InputOutputUserInfo();
updateUserInfo.setUserId(System.currentTimeMillis()+"");
updateUserInfo.setDisplayName("updatedUserName");
@@ -1184,6 +1183,8 @@ public class Main {
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", resultCreateChannel.getResult().getTargetId(), secret);
if (commercialServer) {
//3. 测试channel api功能
IMResult<Void> resultVoid = channelServiceApi.subscribe("userId2");
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
@@ -1200,6 +1201,7 @@ public class Main {
System.out.println("subscribe failure");
System.exit(-1);
}
IMResult<OutputStringList> resultStringList = channelServiceApi.getSubscriberList();
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("userId2") && resultStringList.getResult().getList().contains("userId3")) {
System.out.println("get subscriber done");
@@ -1231,7 +1233,7 @@ public class Main {
System.out.println("get user info failure");
System.exit(-1);
}
}
MessagePayload payload = new MessagePayload();
@@ -1352,4 +1354,61 @@ public class Main {
System.exit(-1);
}
}
/*
会议相关接口,仅音视频高级版服务支持
*/
public static void testConference() throws Exception {
IMResult<PojoConferenceInfoList> listResult = ConferenceAdmin.listConferences();
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get conference list failure");
System.exit(-1);
} else {
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
}
for (PojoConferenceInfo conferenceInfo:listResult.getResult().conferenceInfoList) {
IMResult<Void> destroyResult = ConferenceAdmin.destroy(conferenceInfo.roomId);
if(destroyResult == null || destroyResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("destroy room failure");
System.exit(-1);
} else {
System.out.println("destroy room success");
}
}
listResult = ConferenceAdmin.listConferences();
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get conference list failure");
System.exit(-1);
} else {
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
}
IMResult<Void> createResult = ConferenceAdmin.createRoom("helloroomid", "hello room description", "123456", 20, false, 0, false);
if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("create conference list failure");
System.exit(-1);
} else {
System.out.println("create conference");
}
listResult = ConferenceAdmin.listConferences();
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get conference list failure");
System.exit(-1);
} else {
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
}
for (PojoConferenceInfo conferenceInfo:listResult.getResult().conferenceInfoList) {
IMResult<PojoConferenceParticipantList> listParticipantsResult = ConferenceAdmin.listParticipants(conferenceInfo.roomId);
if(listParticipantsResult == null || listParticipantsResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("destroy room failure");
System.exit(-1);
} else {
System.out.println("destroy room success");
}
}
}
}