public byte[] getScreenShot(String mac) {
        if (!ClientConnectionMap.keySet().contains(mac)) {
            throw new BusinessException("航显ID " + mac + " 不存在");
        }
        Channel channel = ClientConnectionMap.getClientChannelBytoken(mac);
        if (null == channel) {
            throw new BusinessException("连接异常");
        }
        String reqId = UUID.randomUUID().toString();
        FidsScreenShotReq req = new FidsScreenShotReq();
        req.setReqId(reqId);
        channel.writeAndFlush(req);
        FutureTask<byte[]> stringFutureTask = new FutureTask<>(() -> {
            while (true) {
                byte[] img = FidsScreenShotBusiness.map.get(reqId);
                if (null != img) {
                    FidsScreenShotBusiness.map.remove(reqId);
                    return img;
                }
                Thread.sleep(100);
            }
        });
        executorService.submit(stringFutureTask);
        byte[] rest = null;
        try {
            rest = stringFutureTask.get();
        } catch (Exception e) {
            throw new BusinessException("查看航显屏异常");
        }

        return rest;

    }


JAVA     

本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!