(@NotNull Service service, @NotNull Service.ProtocolFactoryHandle<?> factoryHandle)
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public long handle(@NotNull Service service, |
| 286 | @NotNull Service.ProtocolFactoryHandle<?> factoryHandle) throws Exception { |
| 287 | if (isRequest) |
| 288 | return super.handle(service, factoryHandle); |
| 289 | |
| 290 | // response, 从上下文中查找原来发送的rpc对象,并派发该对象。 |
| 291 | Rpc<TArgument, TResult> context = service.removeRpcContext(sessionId); |
| 292 | if (context == null) { |
| 293 | service.onRpcLostContext(this); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | Transaction.tryWhileRedo(() -> service.addRpcContext(sessionId, context)); |
| 298 | |
| 299 | context.setSender(getSender()); |
| 300 | context.resultCode = resultCode; |
| 301 | context.Result = Result; |
| 302 | context.isTimeout = false; // not need |
| 303 | context.isRequest = false; |
| 304 | |
| 305 | if (context.future != null) |
| 306 | context.future.setResult(context.Result); // SendForWait,设置结果唤醒等待者。 |
| 307 | else if (context.responseHandle != null) |
| 308 | return context.responseHandle.handle(context); |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | @Override |
| 314 | public void encode(@NotNull ByteBuffer bb) { |
nothing calls this directly
no test coverage detected