peerbase.sample
Class FileShareNode

java.lang.Object
  extended by peerbase.Node
      extended by peerbase.sample.FileShareNode

public class FileShareNode
extends Node

The backend implementation of a simple peer-to-peer file sharing application. This class mostly implements a simple protocol by defining the appropriate handlers (as inner classes) for the inherited methods of the Node class from the PeerBase system.

Author:
Nadeem Abdul Hamid

Field Summary
static java.lang.String ERROR
           
static java.lang.String FILEGET
           
static java.lang.String INSERTPEER
           
static java.lang.String LISTPEER
           
static java.lang.String PEERNAME
           
static java.lang.String PEERQUIT
           
static java.lang.String QRESPONSE
           
static java.lang.String QUERY
           
static java.lang.String REPLY
           
 
Constructor Summary
FileShareNode(int maxPeers, PeerInfo myInfo)
           
 
Method Summary
 void addLocalFile(java.lang.String filename)
          Register the specified file as being locally available.
 void buildPeers(java.lang.String host, int port, int hops)
           
 java.lang.String[] getFileNames()
           
 java.lang.String getFileOwner(java.lang.String filename)
           
 
Methods inherited from class peerbase.Node
addHandler, addPeer, addPeer, addRouter, connectAndSend, getHost, getId, getMaxPeers, getNumberOfPeers, getPeer, getPeerKeys, getPort, mainLoop, makeServerSocket, makeServerSocket, maxPeersReached, removePeer, sendToPeer, startStabilizer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSERTPEER

public static final java.lang.String INSERTPEER
See Also:
Constant Field Values

LISTPEER

public static final java.lang.String LISTPEER
See Also:
Constant Field Values

PEERNAME

public static final java.lang.String PEERNAME
See Also:
Constant Field Values

QUERY

public static final java.lang.String QUERY
See Also:
Constant Field Values

QRESPONSE

public static final java.lang.String QRESPONSE
See Also:
Constant Field Values

FILEGET

public static final java.lang.String FILEGET
See Also:
Constant Field Values

PEERQUIT

public static final java.lang.String PEERQUIT
See Also:
Constant Field Values

REPLY

public static final java.lang.String REPLY
See Also:
Constant Field Values

ERROR

public static final java.lang.String ERROR
See Also:
Constant Field Values
Constructor Detail

FileShareNode

public FileShareNode(int maxPeers,
                     PeerInfo myInfo)
Method Detail

addLocalFile

public void addLocalFile(java.lang.String filename)
Register the specified file as being locally available.

Parameters:
filename - the name of the file

getFileNames

public java.lang.String[] getFileNames()

getFileOwner

public java.lang.String getFileOwner(java.lang.String filename)

buildPeers

public void buildPeers(java.lang.String host,
                       int port,
                       int hops)