Package it.quizzy.logiclayer.server
Class ServerPartita
java.lang.Object
java.lang.Thread
it.quizzy.logiclayer.server.ServerPartita
- All Implemented Interfaces:
Runnable
Servizio per la creazione di una partita
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.BuilderPREVIEW, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionServerPartita(Function<Integer, Boolean> newClientCallback, BiFunction<Integer, String, Void> valutaRisposta) Costruttore per la creazione di un server per una partita -
Method Summary
Modifier and TypeMethodDescriptionvoidbroadcastMessage(String str) Metodo per inviare a tutti i client un messaggiointgetPort()voidmessageDocente(String str) Metodo per mandare un messaggio al docente che ha creato la partitavoidrun()voidMetodo per interrompere l'accettazione di nuovi client una volta iniziata la partitavoidMetodo per terminare la partita, chiude le connessioni con tutti i client e chiude la socket del servervoidutenteMessage(Integer idClient, String message) Metodo per inviare ad uno specifico client un messaggioMethods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, 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
-
Field Details
-
STOP_STRING
- See Also:
-
-
Constructor Details
-
ServerPartita
public ServerPartita(Function<Integer, Boolean> newClientCallback, BiFunction<Integer, String, Void> valutaRisposta) Costruttore per la creazione di un server per una partita- Parameters:
newClientCallback- callback per la connessione di nuovi clientvalutaRisposta- callback per valutare le risposte
-
-
Method Details
-
run
public void run() -
broadcastMessage
Metodo per inviare a tutti i client un messaggio- Parameters:
str- stringa contenete il messaggio
-
messageDocente
Metodo per mandare un messaggio al docente che ha creato la partita- Parameters:
str-
-
stopAcceptRequest
public void stopAcceptRequest()Metodo per interrompere l'accettazione di nuovi client una volta iniziata la partita -
stopPartita
public void stopPartita()Metodo per terminare la partita, chiude le connessioni con tutti i client e chiude la socket del server -
utenteMessage
Metodo per inviare ad uno specifico client un messaggio- Parameters:
idClient- id del client a cui si desidera inviare il messaggiomessage- stringa contenete il messaggio
-
getPort
public int getPort()- Returns:
- intero con la porta della socket creata
-