Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d0e92d56ff8028682240d3dcf1bd5683b2889201
[simgrid.git] / contrib / psg / src / example / bittorrent / PeerSetMsg.java
1 /*
2  * Copyright (c) 2007-2008 Fabrizio Frioli, Michele Pedrolli
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * --
18  *
19  * Please send your questions/suggestions to:
20  * {fabrizio.frioli, michele.pedrolli} at studenti dot unitn dot it
21  *
22  */
23 package example.bittorrent;
24
25 import peersim.core.*;
26
27 /**
28  *      This class is a {@link SimpleMsg} and represents the <tt>peerset</tt>
29  *      message used by the tracker to send to the peers a list of neighbors.
30  */
31 public class PeerSetMsg extends SimpleMsg{
32         
33         /**
34          *      The set of "friends" peers sent by the tracker to each node.
35          */
36         private Neighbor[] peerSet;
37         
38         /**
39          *      Initializes a new <tt>peerset</tt> message.
40          *      @param type is the type of the message (it should be 12)
41          *      @param array is the array containing the references to the neighbor nodes
42          *      @param sender the sender node
43          *      @see SimpleEvent
44          */
45         public PeerSetMsg(int type, Neighbor []array, Node sender){
46                 super.type = type;
47                 peerSet = array; // references to the effective nodes
48                 super.sender = sender;
49         }
50         
51         /**
52          *      Gets the peer set.
53          *      @return the peer set, namely the set of neighbor nodes.
54          */
55         public Neighbor[] getPeerSet(){
56                 return this.peerSet;    
57         }
58 }