ts3j icon indicating copy to clipboard operation
ts3j copied to clipboard

Client#getUniqueIdentifier() returns empty String

Open moritz-baumgart opened this issue 5 years ago • 5 comments

When iterating over LocalTeamspeakClientSocket#listClients(), Client#getUniqueIdentifier() returns an empty string for every Client.

I did a workaround looking something like this: LocalTeamspeakClientSocket#getClientInfo(Client#getId()).getUniqueIdentifier()

Example:

LocalTeamspeakClientSocket localTeamspeakClientSocket;
...
for (Client client : localTeamspeakClientSocket.listClients()) {

      client .getUniqueIdentifier()   // Returns ""

      localTeamspeakClientSocket.getClientInfo(client.getId()).getUniqueIdentifier()   // Returns unique identifier


}

moritz-baumgart avatar Dec 15 '19 23:12 moritz-baumgart

Thanks for reporting the issue, I'll take a look.

Manevolent avatar Dec 15 '19 23:12 Manevolent

@Manevolent Perfect! I also looked a bit around in the code and found a few odd block comments, e.g. above listChannels() or listClients() in LocalTeamspeakClientSocket.java. These seem to belong to a diffrent method...

moritz-baumgart avatar Dec 16 '19 17:12 moritz-baumgart

Unfortunately, it looks like the listClients() call leverages the client/server query call clientlist. The response object for clientlist returns (from the server),

  • clid
  • cid
  • client_database_id
  • client_nickname
  • client_type

None of these values are a UUID for a client (like a unique identifier), so I don't think I am able to expose a UUID, even if I wanted to, on this method. Ideally, we'd probably track the clients sent through events and expose that via an API as well, but this is more of a long-term goal.

In the mean-time, TS3Listener does adapt for the events that do this, which are: notifycliententerview (corresponds to ClientJoinEvent) notifyclientleftview (corresponds to ClientLeaveEvent)

At least ClientJoinEvent does share the UUID, its properties appear to be:

  • cfid
  • ctid
  • reasonid
  • clid
  • client_unique_identifier
  • client_nickname

... and so forth

Manevolent avatar Dec 16 '19 19:12 Manevolent

I'm going to leave this open, because this is a bit of an eye-sore in the code. I'll start a long-term goal to get better client tracking, and add non-blocking methods to retrieve client information in the project. I suspect we'll need to wrap around the client socket with another class that better abstracts accessing the client state in general.

Manevolent avatar Dec 16 '19 19:12 Manevolent

The clientlist query command has several flags. One of them is -uid which will tell TeamSpeak to also return the client_unique_id field in its answer. 🤔
(The other flags should be -away, -voice, -times, -groups, -info, -icon and -country)

MarkTwoFive avatar Mar 17 '21 22:03 MarkTwoFive