Connection
- Added handling for `AUTH_COMMAND` Server - Added stub `attemptAuth(string, string)` method
This commit is contained in:
parent
322057e8e1
commit
db1d0c2c2a
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue