(@NotNull Service service, @NotNull Service.ProtocolFactoryHandle<?> factoryHandle)
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public void dispatch(@NotNull Service service, |
| 241 | @NotNull Service.ProtocolFactoryHandle<?> factoryHandle) throws Exception { |
| 242 | if (isRequest) { |
| 243 | super.dispatch(service, factoryHandle); |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | // response, 从上下文中查找原来发送的rpc对象,并派发该对象。 |
| 248 | var ctx = service.removeRpcContext(sessionId); |
| 249 | if (ctx == null) { |
| 250 | service.onRpcLostContext(this); |
| 251 | return; |
| 252 | } |
| 253 | var context = setupRpcResponseContext(ctx); |
| 254 | if (context.future != null) |
| 255 | context.future.setResult(context.Result); // SendForWait,设置结果唤醒等待者。 |
| 256 | else if (context.responseHandle != null) |
| 257 | service.dispatchRpcResponse(context, context.responseHandle, factoryHandle); |
| 258 | } |
| 259 | |
| 260 | public Rpc<TArgument, TResult> setupRpcResponseContext(@NotNull Protocol<?> ctx) { |
| 261 | @SuppressWarnings("unchecked") |
no test coverage detected