Class ServerThread
java.lang.Object
java.lang.Thread
ServerThread
- All Implemented Interfaces:
Runnable
ServerThread is a class that extends the Thread class and is used to manage the petitions received from the clients in different threads.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
ExecPetition
(String petition, OutputStream out, InputStream in, String[] petitionTokens) Executes a command in the server.static void
Closes the connection with the client.static void
ListPetition
(String petition, OutputStream out, InputStream in, String[] petitionTokens) Lists the files in the server directory requested by the client.void
Processes the petition received from the client.static void
ReceivePetition
(String petition, OutputStream out, InputStream in, String[] petitionTokens) Receives a file from the client and saves it in the server.void
run()
Starts the thread.static void
SendPetition
(String petition, OutputStream out, InputStream in, String[] petitionTokens) Sends a file to the client.Methods inherited from class java.lang.Thread
activeCount, checkAccess, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Method Details
-
run
public void run()Starts the thread. -
processPetition
public void processPetition()Processes the petition received from the client. -
ListPetition
public static void ListPetition(String petition, OutputStream out, InputStream in, String[] petitionTokens) Lists the files in the server directory requested by the client.- Parameters:
petition
- The petition received from the client.out
- The output stream to send data to the client.in
- The input stream to receive data from the client.petitionTokens
- The tokens of the petition received from the client.
-
SendPetition
public static void SendPetition(String petition, OutputStream out, InputStream in, String[] petitionTokens) Sends a file to the client.- Parameters:
petition
- The petition received from the client.out
- The output stream to send data to the client.in
- The input stream to receive data from the client.petitionTokens
- The tokens of the petition received from the client.
-
ReceivePetition
public static void ReceivePetition(String petition, OutputStream out, InputStream in, String[] petitionTokens) Receives a file from the client and saves it in the server.- Parameters:
petition
- The petition received from the client.out
- The output stream to send data to the client.in
- The input stream to receive data from the client.petitionTokens
- The tokens of the petition received from the client.
-
ExecPetition
public static void ExecPetition(String petition, OutputStream out, InputStream in, String[] petitionTokens) Executes a command in the server.- Parameters:
petition
- The petition received from the client.out
- The output stream to send data to the client.in
- The input stream to receive data from the client.petitionTokens
- The tokens of the petition received from the client.
-
ExitPetition
public static void ExitPetition()Closes the connection with the client.
-