Jump to content

Some Questions


Frederick

Recommended Posts

I am using Trial 1.90.0.1500 in RAD Studio 10S.

1.   How to I call a PHP script which returns a result code and strings, wait for a result and then handle it accordingly?

2.   How to I parse the calling URL for parameter values? (E.g. localhost:8077?param1=value1&param2=value2) Using ParamCount() and ParamStr() from the main module and then referencing the values from the main form does not return any values.

procedure TdtaMain.UniGUIMainModuleCreate(Sender: TObject);
var
   nI : Integer;
begin
   cParam:='';
   for nI := 1 to system.ParamCount do begin
      cParam:=cParam+', '+paramstr(nI);
   end;
end;

3.   Is there a list and details of the properties, events and methods for the Server Module, Main Module and components in UniGui?

4.   Is there a way in design time, to have the details of the UniGui component appear when the F1 key is pressed when the component has focus?

5.   If I call an external URL in situ, is the session automatically terminated and the UniGui application closed?

6.   When deploying an application, which is better for scalability and stability for say, 1,000 concurrent users? Windows service or ISAPI?

Link to comment
Share on other sites

procedure TTransForm.signalEvent(EventID:integer);
begin
  case uniMainModule.polling of
    2: UniSession.AddJS('$.get("http://127.0.0.1:'+uniMainModule.kassePort+'?event='+inttostr(EventID)+'&op='+uniMainModule.initialer+'", function( data ){' +
	 ' ajaxRequest(TransForm.form, ["regEvent"], { response : data });  '+
   ' }); ');
    4: UniSession.AddJS('$.get("http://127.0.0.1:'+uniMainModule.kassePort+'/regevent.php?event='+inttostr(EventID)+'&op='+uniMainModule.initialer+'", function( data ){' +
	 ' ajaxRequest(TransForm.form, ["regEvent"], { response : data });  '+
   ' }); ');
    5: UniSession.AddJS('$.get("http://127.0.0.1:'+uniMainModule.kassePort+'/cgi-bin/regevent.cgi?event='+inttostr(EventID)+'&op='+uniMainModule.initialer+'", function( data ){' +
	 ' ajaxRequest(TransForm.form, ["regEvent"], { response : data });  '+
   ' }); ');
  end;
end;

procedure TTransForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
    Params: TUniStrings);
var resp:string;
begin
  if eventName='regEvent' then 
  begin
    resp:=Params.Values['response'];
    if resp='OK' then 
   begin
     //
   end;
end;

The first function is doing a jQuery http GET to the local webserver doing cross-origin scripting, and option 4 is calling a php script, with 5 calling a cgi exe file, and the first option calling an indy http server running as a windows service. Then just pass along the callback function, and catch this in the ajaxEvent handler, and pick out the response from the php script, or the cgi executable, or the indy server.

Link to comment
Share on other sites

Thank you for the code in response to my first question. Are the two procedures created in a free form? This is quite overwhelming for a newbie in Javascript like me.

In keeping with Delphi's elegance of using components, I would have expected UniGUI to have a TUniServerRequest component that I could drop onto a form or create at runtime. The component would have a URL property which I could enter "https://www.somewebsite.com/somescript.php?action=dosomething". I would then call the Execute() method of the component and in the OnExecuteRequest event of the same component, I could examine the response return value and handle it accordingly.

No such luck?

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...