mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 09:43:37 +02:00
Why the fuck would I do it like that
This commit is contained in:
parent
c560d9d4d9
commit
e1848d9b89
@ -689,10 +689,14 @@ public class DConnection : Thread
|
||||
/* If `get_user_props` (requires: authed, client) */
|
||||
else if(command == Command.GET_USER_PROPS && hasAuthed && connType == ConnectionType.CLIENT)
|
||||
{
|
||||
/* Get all properties */
|
||||
string[] propertyKeys = getProperties();
|
||||
/* Get the username */
|
||||
string username = cast(string)message.data[1..message.data.length];
|
||||
|
||||
/* TODO: This should take in a username */
|
||||
/* Get the user */
|
||||
DConnection connection = server.findUser(username);
|
||||
|
||||
/* Get all properties of the user */
|
||||
string[] propertyKeys = connection.getProperties();
|
||||
|
||||
/* Encode the status */
|
||||
reply ~= [true];
|
||||
|
@ -265,11 +265,14 @@ public class DServer : Thread
|
||||
*/
|
||||
public DConnection findUser(string username)
|
||||
{
|
||||
/* Get all the current connections */
|
||||
DConnection[] connections = getConnections();
|
||||
/* The found Connection */
|
||||
DConnection foundConnection;
|
||||
|
||||
/* Lock the connections list */
|
||||
connectionLock.lock();
|
||||
|
||||
/* Find the user with the matching user name */
|
||||
foreach(DConnection connection; connections)
|
||||
foreach(DConnection connection; connectionQueue)
|
||||
{
|
||||
/* The connection must be a user (not unspec or server) */
|
||||
if(connection.getConnectionType() == DConnection.ConnectionType.CLIENT)
|
||||
@ -277,28 +280,15 @@ public class DServer : Thread
|
||||
/* Match the username */
|
||||
if(cmp(connection.getUsername(), username) == 0)
|
||||
{
|
||||
return connection;
|
||||
foundConnection = connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public DConnection[] getConnections()
|
||||
{
|
||||
/* The current connections list */
|
||||
DConnection[] currentConnections;
|
||||
|
||||
/* Lock the connections list */
|
||||
connectionLock.lock();
|
||||
|
||||
currentConnections = connectionQueue;
|
||||
|
||||
/* Unlock the connections list */
|
||||
connectionLock.unlock();
|
||||
|
||||
return currentConnections;
|
||||
|
||||
return foundConnection;
|
||||
}
|
||||
|
||||
public bool channelExists(string channelName)
|
||||
@ -396,6 +386,8 @@ public class DServer : Thread
|
||||
return status;
|
||||
}
|
||||
|
||||
/* TODO: All these functions can really be re-duced, why am I not using getConnection() */
|
||||
|
||||
/**
|
||||
* Checks whether the given user has the given
|
||||
* property
|
||||
|
Loading…
Reference in New Issue
Block a user