peerbase.sample
Class FileShareNode
java.lang.Object
peerbase.Node
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
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 |
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
FileShareNode
public FileShareNode(int maxPeers,
PeerInfo myInfo)
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)