public class ServerManagementUDP extends ServerManagement
Modifier and Type | Field and Description |
---|---|
private java.net.DatagramSocket |
socket |
baseDirectory, fileListWatcher, logger, punisher, ratioWatcher, server, stop, tracker
Constructor and Description |
---|
ServerManagementUDP(java.lang.String baseDirectory,
HostItem server,
HostItem tracker,
Logger logger)
Constructor for UDP implementation, with baseDirectory and UDPPort parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeSocket()
Closes socket
|
protected <T extends Payload> |
createProtocolP2PPacket(T payload)
Create packets
|
protected java.lang.Object |
getTrackerSocket()
Getter for tracker socket
|
void |
run()
Implementation of runnable.
|
protected void |
writeLog(java.lang.Exception e,
LogLevel logLevel)
Implementation of writeLog
|
protected void |
writeLog(java.lang.String text,
LogLevel logLevel)
Implementation of writeLog
|
handleRequest, sendHashResponse, sendListResponse, sendLoadResponse, sendSizeResponse, sendUnregisterRequest, setStop, updateFileList
sendEmptyDirectory, sendEmptyFile, sendInternalError, sendNotATracker, sendNotFound, sendUnknownHost
public ServerManagementUDP(java.lang.String baseDirectory, HostItem server, HostItem tracker, Logger logger)
baseDirectory
- the root directory where files are storedhostName
- the server will bind on this addressport
- the server will listen on this portlogger
- Logger itemtracker
- Trackerpublic void run()
protected void writeLog(java.lang.String text, LogLevel logLevel)
writeLog
in class ServeErrors
text
- Text to loglogLevel
- level of loggingprotected void writeLog(java.lang.Exception e, LogLevel logLevel)
writeLog
in class ServeErrors
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 ServerManagement
java.net.SocketException
java.net.UnknownHostException
java.io.IOException
protected void closeSocket()
closeSocket
in class ServerManagement