Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5cb1b62bba303c2beafedee0d37796f7aaa77e05
[simgrid.git] / examples / bittorrent / Connection.java
1 package bittorrent;
2
3 import java.util.Arrays;
4
5 public class Connection {
6         /**
7          * Remote peer id
8          */
9         public int id;
10         /**
11          * Remote peer bitfield.
12          */
13         public char bitfield[];
14         /**
15          * Remote peer mailbox
16          */
17         public String mailbox;
18         /**
19          * Indicates if we are interested in something this peer has
20          */
21         public boolean amInterested = false;
22         /**
23          * Indicates if the peer is interested in one of our pieces
24          */
25         public boolean interested = false;
26         /**
27          * Indicates if the peer is choked for the current peer
28          */
29         public boolean chokedUpload = true;
30         /**
31          * Indicates if the peer has choked the current peer
32          */
33         public boolean chokedDownload = true;
34         
35         /**
36          * Constructor
37          */
38         public Connection(int id) {
39                 this.id = id;
40                 this.mailbox = Integer.toString(id);
41         }
42
43         @Override
44         public String toString() {
45                 return "Connection [id=" + id + ", bitfield="
46                                 + Arrays.toString(bitfield) + ", mailbox=" + mailbox
47                                 + ", amInterested=" + amInterested + ", interested="
48                                 + interested + ", chokedUpload=" + chokedUpload
49                                 + ", chokedDownload=" + chokedDownload + "]";
50         }
51         
52         
53 }
54