Ejemplo n.º 1
0
 /* (non-Javadoc)
  * @see edu.tsinghua.lumaqq.qq.net.IPort#send(edu.tsinghua.lumaqq.qq.packets.OutPacket)
  */
 public void send(OutPacket packet) {
   try {
     sendBuf.clear();
     packet.fill(sendBuf);
     sendBuf.flip();
     if (packet.needAck()) {
       channel.write(sendBuf);
       log.debug("已发送 - " + packet.toString());
     } else {
       int count = packet.getSendCount();
       for (int i = 0; i < count; i++) {
         sendBuf.rewind();
         channel.write(sendBuf);
         log.debug("已发送 - " + packet.toString());
       }
     }
   } catch (Exception e) {
     log.error(e.getMessage());
   }
 }
Ejemplo n.º 2
0
 /* (non-Javadoc)
  * @see edu.tsinghua.lumaqq.qq.IPort#send()
  */
 public void send() throws IOException {
   while (!isEmpty()) {
     sendBuf.clear();
     OutPacket packet = remove();
     packet.fill(sendBuf);
     sendBuf.flip();
     if (packet.needAck()) {
       channel.write(sendBuf);
       // 添加到重发队列
       packet.setTimeout(System.currentTimeMillis() + QQ.QQ_TIMEOUT_SEND);
       policy.pushResend(packet, getId());
       log.debug("已发送 - " + packet.toString());
     } else {
       int count = packet.getSendCount();
       for (int i = 0; i < count; i++) {
         sendBuf.rewind();
         channel.write(sendBuf);
         log.debug("已发送 - " + packet.toString());
       }
     }
   }
 }