1
0
mirror of https://github.com/deavminet/dnetd synced 2024-09-21 17:53:39 +02:00

Added default status

This commit is contained in:
Tristan B. Kildaire 2020-10-20 07:57:21 +02:00
parent 93f4ab34ef
commit 759d1623a1

View File

@ -93,6 +93,9 @@ public class DConnection : Thread
/* Initialize locks */ /* Initialize locks */
initLocks(); initLocks();
/* Initialize status */
currentStatus = "available,Hey there I'm using DNET!";
/* Start the connection handler */ /* Start the connection handler */
start(); start();
} }
@ -616,6 +619,7 @@ public class DConnection : Thread
bool status = true; bool status = true;
/* TODO: Implement me */ /* TODO: Implement me */
string user = cast(string)message.data[1..message.data.length];
/* TODO: fetch longontime, serveron, status */ /* TODO: fetch longontime, serveron, status */
string logontime; string logontime;
@ -627,7 +631,7 @@ public class DConnection : Thread
reply ~= logontime; reply ~= logontime;
reply ~= [cast(byte)serveron.length]; reply ~= [cast(byte)serveron.length];
reply ~= serveron; reply ~= serveron;
reply ~= getStatusMessage(); reply ~= server.getStatusMessage(user);
} }
/* If `status` command (requires: authed, client) */ /* If `status` command (requires: authed, client) */
else if(command == Command.STATUS && hasAuthed && connType == ConnectionType.CLIENT) else if(command == Command.STATUS && hasAuthed && connType == ConnectionType.CLIENT)
@ -772,21 +776,23 @@ public class DConnection : Thread
/** /**
* Returns the current status message * Returns the current status message
*/ */
public string getStatusMessage() public string getStatusMessage(string username)
{ {
/* The current status message */ /* The status message */
string currentStatusMessage; string statusMessage;
writeln("hfsjkhfjsdkhfdskj");
/* Lock the status message mutex */ /* Lock the status message mutex */
statusMessageLock.lock(); statusMessageLock.lock();
/* Copy the status message */ /* Get the status message */
currentStatusMessage = currentStatus; statusMessage = currentStatus;
/* Unlock the statue message mutex */ /* Unlock the statue message mutex */
statusMessageLock.unlock(); statusMessageLock.unlock();
return currentStatusMessage; return statusMessage;
} }
public ConnectionType getConnectionType() public ConnectionType getConnectionType()