Add TClientConnection.GetIdentifier in CastleClientServer.pas

TClientConnection = record
private
{$ifndef ANDROID}
OtherID : String;
Context: TIdContext;
{$else}
ID: String;
{$endif}
public
constructor Create({$ifdef ANDROID}AID: String{$else}AContext: TIdContext{$endif});
function GetIdentifier: String;
end;

constructor TClientConnection.Create({$ifdef ANDROID}AID: String{$else}AContext: TIdContext{$endif});
begin
{$ifdef ANDROID}
ID := AID;
{$else}
Context := AContext;
OtherID := IntToStr(Random($8000000)) + IntToStr(NativeUInt(@Context));
{$endif}
end;
function TClientConnection.GetIdentifier: String;
begin
{$ifdef ANDROID}
Result := ID;
{$else}
Result := OtherID;
{$endif}
end;

Than you! But when proposing feature requests and / or patches, you need to:

  1. Describe why do you propose a given code change. What is the benefit from having this, what does it allow to achieve the developer (that is not possible right now, or that is not comfortable now).

  2. Also, the changes are better described as pull request, not by pasting code in a forum. Then we can see the “diff”. See Coding Conventions | Manual | Castle Game Engine , “Submitting your code contributions”.

The “diff”, analyzing your snippets, is that

  • you add OtherID on non-Android, which is random, and not used for anything else.
  • And expose TClientConnection.GetIdentifier: String, from either Id or OtherId.

But I don’t know why. TClientConnection contains now internal information, with platform-specific Context / Id. User code should not need to access them (and consequently, we should not need to invent OtherID).

Please write an explanation why is this necessary for us to include this if you wish to propose adding it to the engine :slight_smile: