mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-27 14:35:11 +08:00
rpc
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.jsowell.netty.rpc;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user