mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +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) */
|
/* If `get_user_props` (requires: authed, client) */
|
||||||
else if(command == Command.GET_USER_PROPS && hasAuthed && connType == ConnectionType.CLIENT)
|
else if(command == Command.GET_USER_PROPS && hasAuthed && connType == ConnectionType.CLIENT)
|
||||||
{
|
{
|
||||||
/* Get all properties */
|
/* Get the username */
|
||||||
string[] propertyKeys = getProperties();
|
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 */
|
/* Encode the status */
|
||||||
reply ~= [true];
|
reply ~= [true];
|
||||||
|
@ -265,11 +265,14 @@ public class DServer : Thread
|
|||||||
*/
|
*/
|
||||||
public DConnection findUser(string username)
|
public DConnection findUser(string username)
|
||||||
{
|
{
|
||||||
/* Get all the current connections */
|
/* The found Connection */
|
||||||
DConnection[] connections = getConnections();
|
DConnection foundConnection;
|
||||||
|
|
||||||
|
/* Lock the connections list */
|
||||||
|
connectionLock.lock();
|
||||||
|
|
||||||
/* Find the user with the matching user name */
|
/* 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) */
|
/* The connection must be a user (not unspec or server) */
|
||||||
if(connection.getConnectionType() == DConnection.ConnectionType.CLIENT)
|
if(connection.getConnectionType() == DConnection.ConnectionType.CLIENT)
|
||||||
@ -277,28 +280,15 @@ public class DServer : Thread
|
|||||||
/* Match the username */
|
/* Match the username */
|
||||||
if(cmp(connection.getUsername(), username) == 0)
|
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 */
|
/* Unlock the connections list */
|
||||||
connectionLock.unlock();
|
connectionLock.unlock();
|
||||||
|
|
||||||
return currentConnections;
|
return foundConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool channelExists(string channelName)
|
public bool channelExists(string channelName)
|
||||||
@ -396,6 +386,8 @@ public class DServer : Thread
|
|||||||
return status;
|
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
|
* Checks whether the given user has the given
|
||||||
* property
|
* property
|
||||||
|
Loading…
Reference in New Issue
Block a user