Показать сообщение отдельно
  #2  
Старый 03.04.2015, 13:03
CynicRus CynicRus вне форума
Прохожий
 
Регистрация: 26.02.2013
Сообщения: 30
Версия Delphi: Lazarus, XE 3.
Репутация: 10
По умолчанию

Если кому потребуется, то проблема решается вот так:
Код:
procedure TPolicyServer.IdTCPServer1Execute(AContext: TIdContext);
var
  strm: TMemoryStream;
  data: TIdBytes;
  s: string;
begin
  if AContext.Connection.Connected then
  begin
    strm := TMemoryStream.Create;
    try
      // read until disconnected
      AContext.Connection.IOHandler.ReadStream(strm,
        AContext.Connection.IOHandler.InputBuffer.Size, false);
      strm.Position := 0;
      ReadTIdBytesFromStream(strm, data, strm.Size);
      // Log('TPolicyServer',BytesToStringRaw(Data));
      s := BytesToStringRaw(data);
      if CompareText(trim('<policy-file-request/>'), trim(s)) = 0 then
      begin
        Log('TPolicyServer', BytesToStringRaw(data));
        Log('TPolicyServer', CrossDomainResponse);
        AContext.Connection.IOHandler.WriteBufferOpen;
        AContext.Connection.IOHandler.Write(CrossDomainResponse);
        AContext.Connection.IOHandler.WriteBufferFlush;
        AContext.Connection.IOHandler.WriteBufferClose;
        AContext.Connection.Disconnect;
      end;

    finally
      strm.Free;
    end;
  end
  else
    Sleep(10);
end;
Ответить с цитированием