更新channel接口,订阅/取消订阅只能逐个操作
This commit is contained in:
@@ -41,18 +41,18 @@ public class ChannelServiceApi {
|
||||
return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||
}
|
||||
|
||||
public IMResult<Void> subscribe(List<String> targets) throws Exception {
|
||||
public IMResult<Void> subscribe(String target) throws Exception {
|
||||
String path = APIPath.Channel_Subscribe;
|
||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||
input.setTargets(targets);
|
||||
input.setTarget(target);
|
||||
input.setSubscribe(1);
|
||||
return httpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
public IMResult<Void> unsubscribe(List<String> targets) throws Exception {
|
||||
String path = APIPath.Channel_Unsubscribe;
|
||||
public IMResult<Void> unsubscribe(String target) throws Exception {
|
||||
String path = APIPath.Channel_Subscribe;
|
||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||
input.setTargets(targets);
|
||||
input.setTarget(target);
|
||||
input.setSubscribe(0);
|
||||
return httpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
@@ -510,7 +510,15 @@ public class Main {
|
||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", inputCreateChannel.getTargetId(), inputCreateChannel.getSecret());
|
||||
|
||||
//3. 测试channel api功能
|
||||
resultVoid = channelServiceApi.subscribe(Arrays.asList("user2","user3"));
|
||||
resultVoid = channelServiceApi.subscribe("user2");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid = channelServiceApi.subscribe("user3");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
} else {
|
||||
@@ -526,7 +534,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid = channelServiceApi.unsubscribe(Arrays.asList("user2"));
|
||||
resultVoid = channelServiceApi.unsubscribe("user2");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
} else {
|
||||
@@ -535,7 +543,7 @@ public class Main {
|
||||
}
|
||||
|
||||
resultStringList = channelServiceApi.getSubscriberList();
|
||||
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user2") && !resultStringList.getResult().getList().contains("user3")) {
|
||||
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user3") && !resultStringList.getResult().getList().contains("user2")) {
|
||||
System.out.println("block user done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
|
||||
Reference in New Issue
Block a user