Jump to content

Using HTTPRequestInfo from servermodule in mainmodule


schliack

Recommended Posts

Hi there,

is there a way to work with the HTTPRequestInfo from Servermodule (UniGUIServerModuleHTTPCommand) in the mainmodule ?

i want to use urls to check Data and give a result back.

So i tried to use 

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
begin
if ARequestInfo.URI='/api/yealink' then
  test( ARequestInfo);
end;

in the Servermodule and the funktion test in the mainmodule.

But then the mainmodule will not be created and i cant use the database Componnents in the Mainmodule cause there ist no safe session.

This will work when there is a little bit time between the calls to unigui. but if there are some at the same time, then there are conflicts to the databasecomponents and i get a systemerror.

Any Ideas about  that ?

 

Cheers and thanks

Andreas

Link to comment
Share on other sites

i want to use urls to check Data and give a result back (API-Server)

Every datapoint is called via URL (/api/yealink , /api/shelly , /api/placetel) and parmeters like authkey .... and sometimes jsondata in the Body.

So i tried to use 

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
begin
if ARequestInfo.URI='/api/yealink' then
  test( ARequestInfo);
end;

in the Servermodule and the funktion test in the mainmodule.

But then the mainmodule will not be created and i cant use the database Componnents in the Mainmodule cause there ist no safe session.

This will work when there is a little bit time between the calls to unigui. but if there are some at the same time, then there are conflicts to the databasecomponents and i get a systemerror.

Any Ideas about  that ?

 

Cheers and thanks

Andreas

Link to comment
Share on other sites

yes, it works while single calls , but if there simultan comming calls, the creation crashes ...

So .. i read that on each call (session) the mainmodule is created and it is only für the session where i can create the database components.

But the mainmodule is only created when i not use TUniServerModule.UniGUIServerModuleHTTPCommand. but i need the TIdHTTPRequestInfo for working with ...

Link to comment
Share on other sites

I use devart unidac and MS SQL / Connection is in datamodule (will be created on function call ( test( ARequestInfo)) and query will bee created on Call) like this:

    datamod := Tdb1_frm.create(nil);
    getcon_sql := TUniQuery.create(nil);
    getcon_ds := TUniDataSource.create(nil);
    getcon_sql.Connection := datamod.sqlcon;
    getcon_ds.DataSet := getcon_sql;

 

 

Link to comment
Share on other sites

  • 4 weeks later...
On 9/15/2023 at 6:55 PM, schliack said:

I use devart unidac and MS SQL / Connection is in datamodule (will be created on function call ( test( ARequestInfo)) and query will bee created on Call) like this:

    datamod := Tdb1_frm.create(nil);
    getcon_sql := TUniQuery.create(nil);
    getcon_ds := TUniDataSource.create(nil);
    getcon_sql.Connection := datamod.sqlcon;
    getcon_ds.DataSet := getcon_sql;

 

 

Hi. Not long ago I gave a detailed answer on connecting to a DBMS and working with connection: 

 

(it example)

remember one connection can only return one set of data at a time, use a connection pool

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...