Forum

Results 1 to 4 of 4
  1. #1
    Join Date
    December 2009
    Location
    Germany
    Posts
    31

    Getting ClientID from UniqueIdentifier

    Hi,

    is it possible to get the clientID from the UniqueIdentifier?

    regards

  2. #2
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    With a little workaround, yes.

    Some like this:
    Code:
    //Returns the client id of the first client found with the unique id cluid, otherwise returns -1
    anyID getClientIdByUniqueId(const char* cluid) {
      anyID* clients;
      anyID foundid = -1;
    
      if (myts3functions.getClientList(serverConnectionHandlerID, &clients) == ERROR_ok) {
        char* uid;
    
        for (int i = 0; clients[i]; ++i) {
          if (myts3functions.getClientVariableAsString(serverConnectionHandler, clients[i], CLIENT_UNIQUE_IDENTIFIER, &uid) == ERROR_ok) {
            if (!strcmp(cluid, uid)
              foundid = clients[i];
            
            myts3functions.freeMemory(&uid);
            
            if (foundid)
              break;
          }      
        }
        
        myts3functions.freeMemory(&clients);
      }
      
      
      return foundid;
    }

  3. #3
    Join Date
    December 2009
    Location
    Germany
    Posts
    31
    Thx, but isn't this a bit ressource intensive ? Or does this loop over the list out of a cache?

  4. #4
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    If you want to cash it, you could implement some callbacks.
    So if some new client joins the server, create some struct or class, in which you store the unique id and the client id (or an array, hash, etc. with the client's id used as identifier).

    If the client left the server, delete the allocated memory.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. invalid clientID
    By BobNLarry in forum Windows
    Replies: 1
    Last Post: December 18th, 2014, 10:27 AM
  2. invalid clientID
    By fuuussiiidiel in forum Permission System
    Replies: 2
    Last Post: April 8th, 2013, 12:45 PM
  3. invalid clientID
    By ShavedApe in forum Server Support
    Replies: 2
    Last Post: February 8th, 2013, 05:01 PM
  4. Client trying to use already in use clientID
    By Superk in forum Linux / FreeBSD
    Replies: 3
    Last Post: March 8th, 2011, 02:05 PM
  5. [BUG] invalid clientID: 0
    By meliorus in forum Bug Reports [EN/DE]
    Replies: 1
    Last Post: August 31st, 2010, 03:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •