mirror of
https://github.com/besterprotocol/besterd
synced 2023-12-13 21:00:32 +01:00
Added isClient
function.
This commit is contained in:
parent
61e0d9f3d3
commit
1fcfaffa28
|
@ -2,6 +2,7 @@ module server.informer.utils;
|
|||
|
||||
import server.server : BesterServer;
|
||||
import connection.connection : BesterConnection;
|
||||
import std.string : cmp;
|
||||
|
||||
/**
|
||||
* This functions returns `string[]` where each element
|
||||
|
@ -22,4 +23,23 @@ public static string[] listClients(BesterServer server)
|
|||
}
|
||||
|
||||
return clientList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns `true` if the provided username
|
||||
* matches a locally connected client, `false` otherwise.
|
||||
*/
|
||||
public static bool isClient(BesterServer server, string username)
|
||||
{
|
||||
for(ulong i = 0; i < server.clients.length; i++)
|
||||
{
|
||||
/* Make sure only to match client connections */
|
||||
BesterConnection connection = server.clients[i];
|
||||
if(connection.getType() == BesterConnection.Scope.CLIENT && cmp(connection.getCredentials[0], username))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
Loading…
Reference in a new issue