public class ClientManagementUDP extends ClientManagement
baseDirectory, client, downLoader, hostList, logger, partsSubdir, tracker
Constructor and Description |
---|
ClientManagementUDP(java.lang.String baseDirectory,
HostItem tracker,
java.lang.String partsSubdir,
Logger logger,
HostItem client)
Constructor for UDP implementation, with baseDirectory, tracker, partsSubdir, logger and scanner parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeHostItemSocket(HostItem hostItem)
Close HostItem socket
|
protected void |
closeTrackerSocket()
Close Tracker socket
|
protected <T extends Payload> |
createProtocolP2PPacket(T payload)
Create packets
|
protected java.lang.Object |
getHostItemSocket(HostItem hostItem)
Getter for HostItem socket
|
protected java.lang.Object |
getTrackerSocket()
Getter for tracker socket
|
protected void |
initDownloader(java.lang.String filename)
Initialize downloader
|
protected void |
writeLog(java.lang.Exception e,
LogLevel logLevel)
Implementation of writeLog
|
protected void |
writeLog(java.lang.String text,
LogLevel logLevel)
Implementation of writeLog
|
download, initHostList, listDirectory
sendEmptyDirectory, sendEmptyFile, sendInternalError, sendNotATracker, sendNotFound, sendUnknownHost
public ClientManagementUDP(java.lang.String baseDirectory, HostItem tracker, java.lang.String partsSubdir, Logger logger, HostItem client)
baseDirectory
- the root directory where files are storedtracker
- tracker HostItempartsSubdir
- subdirectory to store file partslogger
- Logggerclient
- HostItem of the applicationprotected void initDownloader(java.lang.String filename)
initDownloader
in class ClientManagement
filename
- Name of the file to downloadprotected void writeLog(java.lang.String text, LogLevel logLevel)
writeLog
in class ClientManagement
text
- Text to loglogLevel
- level of loggingprotected void writeLog(java.lang.Exception e, LogLevel logLevel)
writeLog
in class ClientManagement
e
- exception to loglogLevel
- level of loggingprotected <T extends Payload> ProtocolP2PPacket<T> createProtocolP2PPacket(T payload)
createProtocolP2PPacket
in class ServeErrors
payload
- Payloadprotected java.lang.Object getTrackerSocket() throws java.net.SocketException, java.net.UnknownHostException, java.io.IOException
getTrackerSocket
in class ClientManagement
java.net.SocketException
java.net.UnknownHostException
java.io.IOException
protected void closeTrackerSocket()
closeTrackerSocket
in class ClientManagement
protected java.lang.Object getHostItemSocket(HostItem hostItem)
getHostItemSocket
in class ClientManagement
hostItem
- HostItemprotected void closeHostItemSocket(HostItem hostItem)
closeHostItemSocket
in class ClientManagement
hostItem
- HostItem