1 /* Copyright (c) 2006-2019. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 package app.bittorrent;
8 import org.simgrid.msg.Task;
10 public class MessageTask extends Task {
24 protected String issuerHostname;
25 protected String mailbox;
27 protected char[] bitfield;
29 protected int blockIndex;
30 protected int blockLength;
31 protected boolean stalled;
33 public MessageTask(Type type, String issuerHostname, String mailbox, int peerId) {
34 this(type,issuerHostname,mailbox,peerId,-1,false,-1,-1);
37 public MessageTask(Type type, String issuerHostname, String mailbox, int peerId, int index) {
38 this(type,issuerHostname,mailbox,peerId,index,false,-1,-1);
41 // builds a new bitfield message
42 public MessageTask(Type type, String issuerHostname, String mailbox, int peerId, char[] bitfield) {
43 this(type,issuerHostname,mailbox,peerId,-1,false,-1,-1);
44 this.bitfield = bitfield;
47 // build a new "request" message
48 public MessageTask(Type type, String issuerHostname, String mailbox, int peerId, int index, int blockIndex,
50 this(type,issuerHostname,mailbox,peerId,index,false,blockIndex,blockLength);
53 // build a new "piece" message
54 public MessageTask(Type type, String issuerHostname, String mailbox, int peerId, int index, boolean stalled,
55 int blockIndex, int blockLength) {
57 this.issuerHostname = issuerHostname;
58 this.mailbox = mailbox;
61 this.stalled = stalled;
62 this.blockIndex = blockIndex;
63 this.blockLength = blockLength;