3

I have been googling all day and keep seeing the same 10 examples for FireMonkey, apptethering and Delphi XE6. I am new to XE6 and app tethering. I thank you for any help I can get.

MY STORY I have Delphi XE6. I am trying to create a tethered FireMonkey application for the android platform. I have a VCL application that will run on a server. There will be many android tablets connecting to the server application at the same time.

The user pushes a button on a tablet which will cause a unique id to be sent to the server using the SendString method of the TTetheringAppProfile. The server has a TetherProfileResourceReceived event and gets the unique id from the AResource.Value. The server queries a database and gets a record. This is all good.

Now I need to send the record back to the SAME profile that sent the request. Every example I have seen uses the item index to get the TTetheringProfileInfo for send string (TetherProfile.Resources.Items[0].Value). I think I can't rely on the index because I will have multiple connections. I want to send the response string right back to the requesting profile.

MY FAILED ATTEMPT

procedure TfrmTabletServer.POSTetherProfileResourceReceived(
  const Sender: TObject; const AResource: TRemoteResource);
var
  RequestID : Integer;
  SendRec := String;
  Requester : String;
begin

Requester := AResource.Name;
if AResource.ResType = TRemoteResourceType.Data then begin     
    RequestID := AResource.Value.AsInteger;
    SendRec := GetRecord(RequestID);
//this works but I cant rely on index name due to multiple connections
//POSTetherProfile.Resources.Items[0].Value = SendRec;

    //I would prefer to use SendString to keep the requests temporary 
    //I can't figure out how to get the TTetheringProfileInfo from the AResource
    POSTetherProfile.SendString('TTetheringProfileInfo from AResource?','Response ' +            ID.AsString, SendRec);
end; 

MY RESOURCE http://docwiki.embarcadero.com/RADStudio/XE6/en/Sharing_Data_with_Remote_Applications_Using_App_Tethering

RRUZ
  • 134,889
  • 20
  • 356
  • 483

1 Answers1

1

After a while trying to get the working I still couldn't find a way of obtaining profile identifier from the parameters sent to the OnResourceReceived event.

The way I have solved this is to append the profile identifier to AResource.Hint string so the Hint looks like

"{OriginalHint};{ProfileID}"

This way I can always find the profile identifier by looking at the hint string.

This is not ideal but it works until we have the profile identifier passed as part of AResource.

prajmus
  • 3,171
  • 3
  • 31
  • 41
sugi007
  • 26
  • 2