Examples of PeerWireMessage


Examples of com.torrent4j.net.peerwire.PeerWireMessage

  @Override
  protected Object encode(ChannelHandlerContext ctx, Channel channel,
      Object msg) throws Exception {
    if (!(msg instanceof PeerWireMessage))
      return msg;
    final PeerWireMessage message = (PeerWireMessage) msg;
    final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();

    if (handshaked && !(message instanceof KeepAliveMessage))
      buffer.writeInt(0x00);
    message.write(buffer);

    return buffer;
  }
View Full Code Here

Examples of com.torrent4j.net.peerwire.PeerWireMessage

    } else {
      if(buffer.readableBytes() == 0)
        return new KeepAliveMessage();
     
      final byte opcode = buffer.readByte();
      final PeerWireMessage message;
      switch (opcode) {
      case CancelMessage.MESSAGE_ID:
        message = new CancelMessage();
        break;
      case BitFieldMessage.MESSAGE_ID:
        message = new BitFieldMessage();
        break;
      case ChokeMessage.MESSAGE_ID:
        message = new ChokeMessage();
        break;
      case HaveMessage.MESSAGE_ID:
        message = new HaveMessage();
        break;
      case InterestedMessage.MESSAGE_ID:
        message = new InterestedMessage();
        break;
      case NotInterestedMessage.MESSAGE_ID:
        message = new NotInterestedMessage();
        break;
      case BlockMessage.MESSAGE_ID:
        message = new BlockMessage();
        break;
      case PortMessage.MESSAGE_ID:
        message = new PortMessage();
        break;
      case RequestMessage.MESSAGE_ID:
        message = new RequestMessage();
        break;
      case UnchokeMessage.MESSAGE_ID:
        message = new UnchokeMessage();
        break;
      default:
        return null;
      }
      message.read(buffer);
      return message;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.