@Override public PingResultInfo ping(PingInfo pingInfo) throws ExecutionException, InterruptedException, TimeoutException { FuturePromise<PingResultInfo> result = new FuturePromise<>(); ping(pingInfo, result); if (pingInfo.getTimeout() > 0) return result.get(pingInfo.getTimeout(), pingInfo.getUnit()); else return result.get(); }
@Override public void ping(PingInfo pingInfo, Promise<PingResultInfo> promise) { int pingId = pingIds.getAndAdd(2); PingInfoCallback pingInfoCallback = new PingInfoCallback(pingId, promise); PingFrame frame = new PingFrame(version, pingId); control(null, frame, pingInfo.getTimeout(), pingInfo.getUnit(), pingInfoCallback); }