Connection

- Added handling for `AUTH_COMMAND`

Server

- Added stub `attemptAuth(string, string)` method
This commit is contained in:
Tristan B. Velloza Kildaire 2023-11-10 00:14:35 +02:00
parent 322057e8e1
commit db1d0c2c2a
2 changed files with 33 additions and 0 deletions

View File

@ -111,6 +111,8 @@ public class Connection : Thread
logger.dbg("BaseMessage type: ", baseMessage.getMessageType());
Command response;
if(baseMessage.getCommandType() == CommandType.NOP_COMMAND)
{
import davinci.c2s.test;
@ -120,6 +122,28 @@ public class Connection : Thread
// TODO: This is for testing, I send the nop back
this.tManager.sendMessage(incomingMessage);
}
// Handle authentication request
else if(baseMessage.getCommandType() == CommandType.AUTH_COMMAND)
{
import davinci.c2s.auth : AuthMessage, AuthResponse;
AuthMessage authMessage = cast(AuthMessage)baseMessage.getCommand();
bool status = this.associatedServer.attemptAuth(authMessage.getUsername(), authMessage.getPassword());
AuthResponse authResp = new AuthMessage();
if(status)
{
authResp.good();
}
else
{
authResp.bad();
}
response = authResp;
}
// Response to send back
this.tManager.sendMessage(response);
}
/**

View File

@ -174,6 +174,15 @@ public class Server
/* Unlock the connection queue */
connectionQLock.unlock();
}
public bool attemptAuth(string username, string password)
{
logger.dbg("Attempting auth with user '", username, "' and password '", password, "'");
// TODO: Implement me
return true;
}
}
version(unittest)