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

Implemented setproperty

This commit is contained in:
Tristan B. Kildaire 2020-10-20 11:24:19 +02:00
parent 70549b8fdb
commit 04e12941fb

View File

@ -748,30 +748,20 @@ public class DConnection : Thread
/* If `set_user_prop` (requires: authed, client) */ /* If `set_user_prop` (requires: authed, client) */
else if(command == Command.SET_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT) else if(command == Command.SET_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT)
{ {
/* Get the <user>,<propertyName>,<propertyValue> */ /* Set the <propertyName>,<propertyValue> */
string[] dataLine = split(cast(string)message.data[1..message.data.length],","); string[] dataLine = split(cast(string)message.data[1..message.data.length],",");
/* Get the username */
string username = dataLine[0];
/* Get the property */ /* Get the property */
string propertyName = dataLine[1]; string propertyName = dataLine[0];
/* Get the property value */ /* Get the property value */
string propertyValue = dataLine[2]; string propertyValue = dataLine[1];
/* Determine if it is a valid property */
bool status = server.isProperty(username, propertyName);
/* Encode the status */ /* Encode the status */
reply ~= [status]; reply ~= [true];
/* Encode the property value if one exists */ /* Set the property value */
if(status) setProperty(propertyName, propertyValue);
{
/* Set the property value */
server.setProperty(username, propertyName, propertyValue);
}
} }
/* If `delete_user_prop` (requires: authed, client) */ /* If `delete_user_prop` (requires: authed, client) */
else if(command == Command.DELETE_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT) else if(command == Command.DELETE_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT)
@ -876,7 +866,7 @@ public class DConnection : Thread
private bool sendUserMessage(string username, string message) private bool sendUserMessage(string username, string message)
{ {
/* Find the user to send to */ /* Find the user to send to */
DConnection user = server.findUser(username); DConnection user = server.findUser(username); /*TODO: Ins erver not just use it directly */
writeln("sendUserMessage(): ", user); writeln("sendUserMessage(): ", user);