| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CountDownLatch; |
| | | |
| | | @Component("VnnoxAPIUtil") |
| | | @AllArgsConstructor |
| | |
| | | |
| | | //@Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | private CountDownLatchUtil countDownLatchUtil; |
| | | |
| | | public static VnnoxAPIUtil getBean() { |
| | | return (VnnoxAPIUtil) SpringContextUtil.getBean("VnnoxAPIUtil"); |
| | |
| | | * 获取token |
| | | */ |
| | | public void getToken() { |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.GET_TOKEN), |
| | | new VnnoxGetTokenRequest().toJson(), |
| | | new CommonHeader(CommonHeader.FORM, false) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.GET_TOKEN), new VnnoxGetTokenRequest().toJson(), new CommonHeader(CommonHeader.FORM, false)); |
| | | |
| | | CommonResponse commonResponse = JSON.parseObject(result, CommonResponse.class); |
| | | VnnoxGetTokenResponse response = new VnnoxGetTokenResponse().parse(commonResponse); |
| | |
| | | urlParameters.add(new BasicNameValuePair("start", start.toString())); |
| | | urlParameters.add(new BasicNameValuePair("name", name)); |
| | | |
| | | String result = VnnoxRequestUtil.GetWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.GET_PLAYER_LIST), |
| | | urlParameters, |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.GetWithHeader(VnnoxUrl.getUrl(VnnoxUrl.GET_PLAYER_LIST), urlParameters, new CommonHeader(CommonHeader.JSON, true)); |
| | | return new VnnoxPlayerListResponse().parse(JSON.parseObject(result, CommonResponse.class)); |
| | | } |
| | | |
| | |
| | | VnnoxSyncCurrentInfoRequest vnnoxSyncCurrentInfoRequest = new VnnoxSyncCurrentInfoRequest(); |
| | | vnnoxSyncCurrentInfoRequest.setPlayerIds(playerIds); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SYNC_CURRENT_INFO), |
| | | vnnoxSyncCurrentInfoRequest.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SYNC_CURRENT_INFO), vnnoxSyncCurrentInfoRequest.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | |
| | | VnnoxSyncCurrentInfoResponse response = JSON.parseObject(result, VnnoxSyncCurrentInfoResponse.class); |
| | | |
| | |
| | | vnnoxScreenStatusRequest.setPlayerIds(playerIds); |
| | | vnnoxScreenStatusRequest.setStatus(type); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SCREEN_STATUS), |
| | | vnnoxScreenStatusRequest.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SCREEN_STATUS), vnnoxScreenStatusRequest.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | |
| | | request.setPlayerIds(playerIds); |
| | | request.setValue(vol); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.CHANGE_VOL), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.CHANGE_VOL), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | request.setPlayerIds(playerIds); |
| | | request.setValue(brightness); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.CHANGE_BRIGHTNESS), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.CHANGE_BRIGHTNESS), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | request.setPlayerIds(players); |
| | | request.setNoticeUrl(VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SCREEN_SHOT), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SCREEN_SHOT), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | request.setPlayerIds(players); |
| | | request.setNoticeUrl(VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SCREEN_SHOT), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SCREEN_SHOT), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | |
| | | if (result.startsWith("{") && result.endsWith("}")) { |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | |
| | | request.setPlayerIds(playerIdList); |
| | | request.setNoticeUrl(VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.REBOOT), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.REBOOT), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | request.setOption(option); |
| | | request.setNoticeUrl(VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SIMU_LCAST), |
| | | request.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SIMU_LCAST), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | map.put("noticeUrl", VnnoxConstant.SCREEN_SHOT_NOTIFY_URL); |
| | | map.put("playerIds", playerId); |
| | | String s = JSON.toJSONString(map); |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.NTP_SYNC), |
| | | s, |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.NTP_SYNC), s, new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | |
| | | return response.getData(); |
| | |
| | | VnnoxSyncCurrentInfoRequest vnnoxSyncCurrentInfoRequest = new VnnoxSyncCurrentInfoRequest(); |
| | | vnnoxSyncCurrentInfoRequest.setPlayerIds(playerIds); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader( |
| | | VnnoxUrl.getUrl(VnnoxUrl.SYNC_CURRENT_INFO), |
| | | vnnoxSyncCurrentInfoRequest.toJson(), |
| | | new CommonHeader(CommonHeader.JSON, true) |
| | | ); |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.SYNC_CURRENT_INFO), vnnoxSyncCurrentInfoRequest.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | |
| | | VnnoxSyncCurrentInfoResponse response = JSON.parseObject(result, VnnoxSyncCurrentInfoResponse.class); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取音量,亮度 |
| | | */ |
| | | public VnnoxResultResponse asyncStatus(List<String> playerId) { |
| | | List<String> commands = new ArrayList<>(); |
| | | commands.add("volumeValue"); |
| | | commands.add("brightnessValue"); |
| | | VnnoxBaseRequest request = new VnnoxBaseRequest(); |
| | | request.setPlayerIds(playerId); |
| | | request.setCommands(commands); |
| | | request.setNoticeUrl(VnnoxConstant.STATUS_NOTIFY_URL); |
| | | |
| | | String result = VnnoxRequestUtil.PostWithHeader(VnnoxUrl.getUrl(VnnoxUrl.ASYNCURRENTSTATUS), request.toJson(), new CommonHeader(CommonHeader.JSON, true)); |
| | | VnnoxResultResponse response = JSON.parseObject(result, VnnoxResultResponse.class); |
| | | System.out.println(response.toString()); |
| | | int size = response.getData().getSuccess().size(); |
| | | CountDownLatch countDownLatch = new CountDownLatch(size * 2); |
| | | countDownLatchUtil.push(response.getLogid(), countDownLatch); |
| | | try { |
| | | countDownLatch.await(); |
| | | countDownLatchUtil.remove(response.getLogid()); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return response; |
| | | } |
| | | } |