1
0
Fork 0
mirror of https://github.com/besterprotocol/besterd synced 2023-12-13 21:00:32 +01:00

Added isClient function.

This commit is contained in:
Tristan B. Kildaire 2020-05-04 22:35:07 +02:00
parent 61e0d9f3d3
commit 1fcfaffa28

View file

@ -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;
}