/** * 触发超时事件 * * @param p */ private void fireOperationTimeOutEvent(OutPacket packet, String portName) { ErrorPacket error = new ErrorPacket(ErrorPacket.ERROR_TIMEOUT, client.getUser()); error.timeoutPacket = packet; error.setHeader(packet.getHeader()); error.setFamily(packet.getFamily()); client.addIncomingPacket(error, portName); }
/* (non-Javadoc) * @see java.util.concurrent.Callable#call() */ public T call() throws Exception { long t = getTimeoutLeft(); while (t <= 0) { OutPacket packet = remove(); // 发送 IConnection port = client.getConnection(portName); if (port != null && packet != null && !port.getPolicy().isReplied(packet, false)) { if (packet.needResend()) { // 重发次数未到最大,重发 client.sendPacketAnyway(packet, portName); } else { // 触发操作超时事件 fireOperationTimeOutEvent(packet, portName); } } t = getTimeoutLeft(); } QQClient.executor.schedule(this, t, TimeUnit.MILLISECONDS); return null; }