【问题标题】:How to ensure that messages sent with TTetheringAppProfile.SendStream were delivered properly?如何确保使用 TTetheringAppProfile.SendStream 发送的消息正确传递?
【发布时间】:2015-04-15 15:44:43
【问题描述】:

我有一个简单的移动应用程序,它拍摄一系列照片并通过 SendStream() 将其发送到连接的个人资料。

myTetherAppProfile.SendStream(myTetherManager.RemoteProfiles[idConnected],
                              'ImageData',
                              bmpStreamData);

这里发生的问题是接收器应用程序没有根据连接强度获取所有图像流(接收器应用程序上没有触发 ResourceReceived-Event)。

如果我收到交付失败的响应,这将没有问题。但我不明白(SendStream() 返回“True”)

除了实现“如果您收到我的图像,请用另一条消息回答”功能之外,是否有其他可能实现即使在连接不良的情况下也能实现稳定传输?还是 App-Tethering 默认设计为有损?

此外,在一大堆图像之后,我有时会收到“对等方重置连接”错误。 (我不确定这个错误是否与实际问题有关,所以我更喜欢发布它。)

【问题讨论】:

    标签: firemonkey delphi-xe7 tethering


    【解决方案1】:

    从System.Tether.AppProfile(XE8版本)看相关代码,貌似是bug。请参阅下面的内联 cmets。请举报https://quality.embarcadero.com

    function TTetheringAppProfile.SendStream(const AProfile: TTetheringProfileInfo; const Description: string;
      const AStream: TStream): Boolean;
    var
      LProfileInfo: TTetheringProfileInfo;
      LConnection: TTetheringConnection;
      LCommand: TTetheringCommand;
    begin
      if not FindProfile(AProfile.ProfileIdentifier, LProfileInfo) then
        raise ETetheringException.CreateFmt(SNoProfile, [AProfile.ProfileIdentifier]);
      CheckProfileIsConnected(AProfile);
      LConnection := GetConnectionTo(AProfile);
      TMonitor.Enter(LConnection);
      try
        LCommand := LConnection.Protocol.SendCommandWithResponse(SendStreamCommand, Version, Description);
        if LCommand.Command = SendStreamOkResponse then
        begin
          Result := LConnection.Protocol.TransferStream(AStream);
          if Result then
          begin    <-- Result here is guaranteed to be True
            LCommand := LConnection.Protocol.ReceiveCommand;
            if LCommand.Command = SendStreamContentOKResponse then
              Result := True;  <-- Sets Result to True if succeeds, 
                  <-- but nothing to set Result to False if call failed.
          end;
        end
        else
          Result := False;
      finally
        TMonitor.Exit(LConnection);
      end;
    end;
    

    【讨论】:

      猜你喜欢
      • 2017-10-16
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2018-06-28
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多