Jump to content

PHP talk to client side application?


gibbonuk

Recommended Posts

Hi, just wondering the best way to go about this.

 

I have my own web server hosting my PHP website and i want to communicate with a local application (programming by myself in delphi) that with a request from PHP *does somthing* and returns some small data to PHP or puts the data directly into an sql DB for php to read it.

 

I orginally thought about the "php request" to go into a mysql database where my application is always "looking" for a request, but its not really viable and im sure there are better ways.

 

Anyone got some good ideas! :)

 

Thanks

 

Link to comment
Share on other sites

Ok, ill explain more whats happening.

 

I have a delphi app that collects data from some hardware through the serial port, that all works ETC. It collects the data every 30 mins and puts it into a mysql database every 30 mins.

 

But, what i would like is to let users go onto a webpage, press a button and it sends a message to the delphi app to go collect the data, instead of waiting for the next 30 minute request.

 

I have a my own web host server, running the php website that display the data from the mysql, and also the delphi app is running on that webserver.

 

The bit i dont know how to do is, the part when the user presses a button/link/dont mind and which tells the delphi app to do whatever.

 

Thanks

Andy

Link to comment
Share on other sites

There are a couple of ways that you could do it.  If you write a copy of your update program without the timer component and have it run the update without a visible form then auto application.terminate when it has completed the update you could call that application using a shellexe() function from php.  Alternativly you could set up an Indy listerning server in your current app and fire a command through to it from the php page that initates the update.

 

Either way, the pascal will be a bigger pain than the PHP will be.

Link to comment
Share on other sites

There are ways to do "push" functionality with a web server, but I am no means an expert on it. Is there some reason you cannot simply increase the polling frequency for your delphi app? If it is a process that take a lot of time/resources I can think of one simple solution with regular "pull" functionality.

 

On the web app allow users to select an option to have new data collected which, in turn, stores a flag in the database. Also, have the delphi app store a timestamp in the database every time it performs the operation to collect & store new data.

 

Lastly, increase the polling of the delphi app to 1 minute (or whatever interval you choose) and instead of it automatically performing the data collecting process, instead have it make a call to the web app. Use that call to a PHP script which will determine if new data need to be collecting using the following logic: if 1) the flag has been set in the database (remember to clear the flag) OR 2) it has been at least 30 minutes since the last time data was collected. Although, the delphi app would be doing a call to the web app every minute it wouldn't perform the data collecting/updating process unless someone requested an update or the data is 30 minutes old. The call it makes to make that check would be minor and shouldn't have any performance/resource issues.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.