/** * Poll system time of PC * * @return system time of PC */ public long pollingTime() { /** * Send {@link RequestTimeMsg} to PC in a new thread. You cannot use network connection on the * Main UI thread. Otherwise you will get {@link NetworkOnMainThreadException} */ SocketUtil.INSTANCE.sendMsgInNewThread(new RequestTimeMsg(), host_socket); ResponseTimeMsg responseTimeMsg = this.receiveResponseTimeMsgInNewThread(); return responseTimeMsg.getHostPCTime(); }
/** * Wait for and receive {@link ResponseTimeMsg} from PC. * * @return {@link ResponseTimeMsg} from PC */ public ResponseTimeMsg receiveResponseTimeMsgInNewThread() { Message msg = SocketUtil.INSTANCE.receiveMsgInNewThread(host_socket); assert msg.getType() == Message.RESPONSE_TIME_MSG; return (ResponseTimeMsg) msg; }
/** Receive {@link AuthMsg} from PC; Enable the time-polling functionality. */ public void receiveAuthMsg() { SocketUtil.INSTANCE.receiveMsg(host_socket); }