mirror of
https://github.com/binlaab/nanofiles.git
synced 2026-07-01 22:40:46 +02:00
uwu
This commit is contained in:
@@ -223,22 +223,39 @@ public class NFController {
|
||||
* clientStatus.
|
||||
*/
|
||||
boolean commandAllowed = true;
|
||||
switch (currentCommand) {
|
||||
case NFCommands.COM_MYFILES: {
|
||||
commandAllowed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case NFCommands.COM_PING: {
|
||||
|
||||
// ?????
|
||||
}
|
||||
|
||||
default:
|
||||
// System.err.println("ERROR: undefined behaviour for " + currentCommand + "
|
||||
// command!");
|
||||
}
|
||||
return commandAllowed;
|
||||
switch (currentCommand) {
|
||||
//Comandos SIEMPRE permitidos
|
||||
case NFCommands.COM_MYFILES:
|
||||
case NFCommands.COM_QUIT:
|
||||
case NFCommands.COM_HELP:
|
||||
case NFCommands.COM_NICK:
|
||||
commandAllowed = true;
|
||||
break;
|
||||
//Comandos permitidos:OFFLINE
|
||||
case NFCommands.COM_PING:
|
||||
commandAllowed = (currentState == OFFLINE);
|
||||
if (!commandAllowed) {
|
||||
System.err.println("* Ya estás conectado al directorio. No necesitas hacer ping de nuevo.");
|
||||
}
|
||||
break;
|
||||
//Comandos permitidos:ONLINE
|
||||
case NFCommands.COM_FILELIST_DIR:
|
||||
case NFCommands.COM_PEERLIST:
|
||||
case NFCommands.COM_SERVE:
|
||||
case NFCommands.COM_DOWNLOAD_DIR:
|
||||
case NFCommands.COM_FILELIST_PEER:
|
||||
case NFCommands.COM_DOWNLOAD_PEER:
|
||||
commandAllowed = (currentState == ONLINE);
|
||||
if (!commandAllowed) {
|
||||
System.err.println("* Comando no permitido en estado OFFLINE. Haz un 'ping' primero.");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
commandAllowed = false;
|
||||
System.err.println("ERROR: undefined behaviour for " + currentCommand + " command!");
|
||||
}
|
||||
return commandAllowed;
|
||||
}
|
||||
|
||||
private void updateCurrentState(boolean success) {
|
||||
@@ -248,12 +265,27 @@ public class NFController {
|
||||
* siguiente estado y así permitir unos u otros comandos en cada caso.
|
||||
*/
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
switch (currentCommand) {
|
||||
default:
|
||||
}
|
||||
|
||||
return; //Si falla, no cambiamos de estado
|
||||
}
|
||||
|
||||
switch (currentCommand) {
|
||||
case NFCommands.COM_PING:
|
||||
currentState = ONLINE;
|
||||
break;
|
||||
|
||||
case NFCommands.COM_QUIT:
|
||||
currentState = OFFLINE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
* Los únicos comandos que cambian el estado del autómata son el
|
||||
* 'ping' para ponerlo en ONLINE, y el 'quit' para ponerlo en
|
||||
* OFFLINE, por lo tanto, los demás comandos no alterarán el
|
||||
* estado del autómata
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showMyLocalFiles() {
|
||||
|
||||
Reference in New Issue
Block a user