Jump to content
DidierXT

WebWorker and InitAnimationFrameShim

Recommended Posts

Hi,

I'm trying to setup a webworker to send a file to a RO server.
But I've got this error:

Uncaught ReferenceError: window is not defined
=> function InitAnimationFrameShim() {

 

I thought about SmartCL.WebWorker, but it is working without error in the demo projects.
Also other commands from the same server are working just fine in the application...

Here is the code:

uses System, WorkerThreadUploader;
{$IFDEF SMART_INTERNAL_HANDLE_EXCEPTIONS}
try
{$ENDIF}
  var Thread := TThread.Create;
{$IFDEF SMART_INTERNAL_HANDLE_EXCEPTIONS}
except
  on e: Exception do
    asm console.error(e) end;
end;

// ------------------------------------------------------------------------

unit WorkerThreadUploader;
interface
uses
  SmartCL.WebWorker, RemObjectsSDK, CheckLibrary_intf, Commons;
type
  TThread = class(TWebWorkerThread)
  private
    FROServeur : TCheckService;
    FROChannel : TROHTTPClientChannel;
    FROMessage : TROJSONMessage;
    FMyFile  : TMyFile;
    procedure InitializeRemobjects;
  public
    constructor Create;
    procedure ReceiveMessage(data: Variant); override;
  end;
  TMyFile = class (JObject)
    name    : string;
    content : variant;
  end;
const
  SERVER_ADDRESS = 'http://localhost:8823/json';

implementation

constructor TThread.Create;
begin
  inherited Create;
  InitializeRemobjects();
end;

procedure TThread.InitializeRemobjects;
begin
  FROChannel := TROHTTPClientChannel.Create(SERVER_ADDRESS);
  FROMessage := TROJSONMessage.Create();
  FROServeur := TCheckService.Create(FROChannel, FROMessage);
end;

procedure TThread.ReceiveMessage(Data: Variant);
begin
  FMyFile := TMyFile(Data);
  FROServeur.AddPhoto(
    FMyFile.name,
    FMyFile.content,
    procedure (aResult: AnsiString)
    begin
      PostMessage(Format('File sent: %s ', [FMyFile.name]));
    end,
    procedure (aMessage: TROMessage; aError: JError)
    begin
      PostMessage(Format('Send error: %s ', [FMyFile.name]));
    end
    );
end;

end.

 

 

Share this post


Link to post
Share on other sites

Seems I can't retrieve information.

I'll send you a test case: SMS 3.0.2.20 - Delphi 10.3.2 - RemObjects 9.6

Server : NewProject.exe
Client windows : NewProjectClient.exe  OK
Client SMS : sms_ro.sproj  NO DATA
Client JS : test_client.html  NO DATA

test_ro_sms.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×