novikov.alexander Posted June 27, 2017 Posted June 27, 2017 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! Quote
delagoutte Posted June 27, 2017 Posted June 27, 2017 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 Quote
novikov.alexander Posted June 27, 2017 Author Posted June 27, 2017 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? Quote
novikov.alexander Posted June 27, 2017 Author Posted June 27, 2017 I think the best is share via database No problem if client is PC user. But in my situation client that must write in DB is esp8266 wifi module. This thing can only connect and send a request like "demo:1234@192.168.xxx.1:8077/?luxs=46&onoff=0". Thank you for help! Quote
delagoutte Posted June 27, 2017 Posted June 27, 2017 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) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.