修改重构引入的部分问题

This commit is contained in:
imhao183
2021-04-23 10:22:50 +08:00
parent 49fcc73f78
commit d99e9a079d
8 changed files with 27 additions and 28 deletions
@@ -116,7 +116,10 @@ abstract public class ChannelAction extends Action {
}
protected void sendApiMessage(String topic, byte[] message, Callback callback) {
ServerAPIHelper.sendRequest(channelInfo.getOwner(), null, topic, message, new ServerAPIHelper.Callback() {
sendApiMessage(channelInfo.getOwner(), topic, message, callback);
}
protected void sendApiMessage(String user, String topic, byte[] message, Callback callback) {
ServerAPIHelper.sendRequest(user, null, topic, message, new ServerAPIHelper.Callback() {
@Override
public void onSuccess(byte[] response) {
callback.onSuccess(response);
@@ -19,7 +19,6 @@ import com.xiaoleilu.loServer.RestResult;
import com.xiaoleilu.loServer.annotation.HttpMethod;
import com.xiaoleilu.loServer.annotation.Route;
import com.xiaoleilu.loServer.handler.Request;
import com.xiaoleilu.loServer.handler.Response;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.FullHttpRequest;
@@ -34,7 +33,7 @@ public class SubscriberChannelAction extends ChannelAction {
public boolean action(Request request) {
if (request.getNettyRequest() instanceof FullHttpRequest) {
InputChannelSubscribe input = getRequestBody(request.getNettyRequest(), InputChannelSubscribe.class);
if (input != null && !StringUtil.isNullOrEmpty(input.getTarget())) {
if (input != null && !StringUtil.isNullOrEmpty(input.getUserId())) {
if(input.getSubscribe() > 0 && (channelInfo.getStatus() & ProtoConstants.ChannelState.Channel_State_Mask_Active_Subscribe) == 0) {
response.setStatus(HttpResponseStatus.OK);
RestResult result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_RIGHT);
@@ -42,7 +41,7 @@ public class SubscriberChannelAction extends ChannelAction {
return true;
}
WFCMessage.ListenChannel listenChannel = WFCMessage.ListenChannel.newBuilder().setChannelId(channelInfo.getTargetId()).setListen(input.getSubscribe()).build();
sendApiMessage(IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
sendApiMessage(input.getUserId(), IMTopic.ChannelListenTopic, listenChannel.toByteArray(), result -> {
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeBytes(result);
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());