3

我整天都在谷歌上搜索,并不断看到 FireMonkey、apptethering 和 Delphi XE6 的 10 个相同示例。我是 XE6 和应用程序共享的新手。我感谢您提供的任何帮助。

我的故事 我有 Delphi XE6。我正在尝试为 android 平台创建一个绑定的 FireMonkey 应用程序。我有一个将在服务器上运行的 VCL 应用程序。将有许多安卓平板电脑同时连接到服务器应用程序。

用户按下平板电脑上的按钮,这将导致使用 TTetheringAppProfile 的 SendString 方法将唯一 ID 发送到服务器。服务器有一个 TetherProfileResourceReceived 事件并从 AResource.Value 中获取唯一 ID。服务器查询数据库并获取记录。这一切都很好。

现在我需要将记录发送回发送请求的 SAME 配置文件。我看到的每个示例都使用项目索引来获取发送字符串的 TTetheringProfileInfo (TetherProfile.Resources.Items[0].Value)。我想我不能依赖索引,因为我会有多个连接。我想将响应字符串直接发送回请求配置文件。

我失败的尝试

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; 

我的资源 http://docwiki.embarcadero.com/RADStudio/XE6/en/Sharing_Data_with_Remote_Applications_Using_App_Tethering

4

1 回答 1

1

尝试了一段时间后,我仍然找不到从发送到OnResourceReceived事件的参数中获取配置文件标识符的方法。

我解决这个问题的方法是将配置文件标识符附加到AResource.Hint字符串,所以提示看起来像

"{OriginalHint};{ProfileID}"

这样,我总是可以通过查看提示字符串找到配置文件标识符。

这并不理想,但在我们将配置文件标识符作为AResource.

于 2015-02-18T14:12:58.017 回答