Files
jsowell-charger-web/jsowell-pile/src/main/java/com/jsowell/pile/rpc/RpcResponseHandler.java
2024-08-01 18:03:21 +08:00

26 lines
837 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.jsowell.pile.rpc;
import com.jsowell.common.protocol.RpcResponse;
import com.jsowell.common.protocol.SyncPromise;
import com.jsowell.common.util.RpcUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
public class RpcResponseHandler extends SimpleChannelInboundHandler<RpcResponse> {
@Override
protected void channelRead0(ChannelHandlerContext ctx, RpcResponse msg) throws Exception {
// 根据请求id在集合中找到与外部线程通信的SyncPromise对象
SyncPromise syncPromise = RpcUtil.getSyncPromiseMap().get(msg.getId());
if(syncPromise != null) {
// 设置响应结果
// syncPromise.setRpcResponse(msg);
// 唤醒外部线程
syncPromise.wake();
}
}
}