| | |
| | | boolean reConnectSocket; |
| | | SocketUtil socketUtil = new SocketUtil(); |
| | | while (true) { |
| | | // System.out.println("GuestSocketClient.run 1"); |
| | | // System1.out.println("GuestSocketClient.run 1"); |
| | | try { |
| | | lastUpdateTime = System.currentTimeMillis(); |
| | | reConnectSocket = false; |
| | | try { |
| | | String outdoorServerIp = ""; |
| | | List<String> outdoorDeviceIpList = RemoteOutdoorManager.getOutdoorDeviceIp(); |
| | | // System1.out.println("IndoorGuestSocketClient.run outdoorDeviceIpList="+outdoorDeviceIpList); |
| | | if (outdoorDeviceIpList.size() > 0) { |
| | | outdoorServerIp = outdoorDeviceIpList.get(0); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | serverIp = outdoorServerIp; |
| | | // System1.out.println("IndoorGuestSocketClient.run serverIp="+serverIp); |
| | | } catch (Exception e) { |
| | | System.out.println("GuestSocketClient.run 1 " + e.getMessage()); |
| | | System1.out.println("GuestSocketClient.run 1 " + e.getMessage()); |
| | | SystemClock.sleep(1000); |
| | | continue; |
| | | } |
| | |
| | | MainActivity activity = BaseApplication.getApplication().activity; |
| | | activity.runOnUiThread(() -> { |
| | | try { |
| | | FragmentUtil.guestModeFragment().camera1.setImageBitmap(image); |
| | | // System1.out.println("IndoorGuestSocketClient.onBitmap "); |
| | | activity.fragment_camera.camera2.setImageBitmap(image); |
| | | // FragmentUtil.guestModeFragment().camera1.setImageBitmap(image); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | Type listType = new TypeToken<List<Map<String, String>>>() { |
| | | }.getType(); |
| | | List<Map<String, String>> faces = new Gson().fromJson(facePositionsJson, listType); |
| | | // System1.out.println("IndoorGuestSocketClient.detectFace " + faces + " " + guestListCameraType + " facePositionsJson="+facePositionsJson); |
| | | FragmentUtil.guestModeFragment().addGuestList(faces, guestListCameraType, image, featureArray); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | }); |
| | | while (!Thread.currentThread().isInterrupted() && !reConnectSocket) { |
| | | // System.out.println("GuestSocketClient.run 6"); |
| | | // System1.out.println("GuestSocketClient.run 6"); |
| | | lastUpdateTime = System.currentTimeMillis(); |
| | | Map<String, String> requestMap = new HashMap<>(); |
| | | requestMap.put(RemoteCameraMessage.requestFrame, BaseApplication.getApplication().activity.requestFrame()); |
| | |
| | | } catch (Exception e) { |
| | | if (e instanceof NoRouteToHostException) { |
| | | } else { |
| | | System.out.println("GuestSocketClient.run 3 " + e.getMessage()); |
| | | System1.out.println("GuestSocketClient.run 3 " + e.getMessage()); |
| | | } |
| | | SystemClock.sleep(1000); |
| | | SystemClock.sleep(3000); |
| | | } finally { |
| | | socketUtil.close(); |
| | | } |