Jump to content

How to Passing parameters (values) between sessions


novikov.alexander

Recommended Posts

I need to make one client send parameters, and others read them. I do not understand how to do this. Here is an example:

 

   in browser i sent "demo:1234@192.168.xxx.1:8077/?luxs=46&onoff=0"

procedure TMainForm.UniTimer1Timer(Sender: TObject);
begin
  if UniApplication.Parameters.Values['luxs']<>'' then lux1:=strtoint(UniApplication.Parameters.Values['luxs']);
  UniProgressBar1.Position:= lux1;
end;

It's work fine for client who sent it. But not for all client sessions.

Trying to do an analysis leads to exception:

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);

begin
  if ARequestInfo.AuthExists and (ARequestInfo.AuthPassword='1234') and (ARequestInfo.AuthUsername='demo') then
  begin
    if ARequestInfo.Params.Values['luxs']<>'' then MainForm.lux1:=strtoint(ARequestInfo.Params.Values['luxs']);
    Exit; // Authentication is successful
  end
  else
  begin
    AResponseInfo.AuthRealm := 'Enter credentials for ' + Title;
    handled:=True;
  end;
end;

If you have simple code examples, please write them in this thread/

 

Thank u!

 

 

Link to comment
Share on other sites

mainform is private for each session.

try to see demo session list for access property of other session but becarefull this method lock the session during the process.

So you could use a database or file to share information between session

Link to comment
Share on other sites

mainform is private for each session.

try to see demo session list for access property of other session but becarefull this method lock the session during the process.

So you could use a database or file to share information between session

Thank you so much.

I have another question:

I need to make the procedure of writing to the database which execute when some client(esp8266 wifi module) sending http requests. And after that other clients(PC) must refresh their data (timer can do this, but maybe someone have more elegant method to do this) . 

Which way is the best for identification client and for determine type of client request (post or get)? How can i use TUniServerModule.UniGUIServerModuleHTTPCommand for insert into database?

Does anybody have samples?

Link to comment
Share on other sites

it is not the client that write on database.

your client send the request like "demo:1234@192.168.xxx.1:8077/?luxs=46&onoff=0"

the web server (unigui app)receive the request and do " if UniApplication.Parameters.Values['luxs'] <> '' then SaveParamLuxsInDB".

 

For other client, i don't konw if you  want a big reactivity but you could have a timer that read luxs value in database. so if you want more reactivity you could uses event of database (exemple with firebrd : POST_EVENT)

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...