PHP + Delphi(Pascal), issue real-time warnings

Asked

Viewed 1,195 times

12

I would like to design a small, simple system encoded in the Pascal language (IDE Delphi), to receive notifications (such as a warning that an event has occurred), upon receiving the warning play some sound.

I know little of Delphi, it was one of the languages I started just out of curiosity but I ended up leaving after I came to WEB platform.

I don’t know if it is possible, create something with PHP + Delphi, something like send an email, the software capture and send some warning (like a sound) to the client.

I would like it to be possible to connect to Delphi with PHP, but I do not know if it is possible to interact a language of the web platform with another that is not, directly.

  • 1

    Your software running on client and in PHP?

  • 1

    Provides more information on the question, maybe there is a solution, I’m having difficulty understanding what you that.

  • I want to know the way to create a program capable of receiving notifications from a WEB platform language( as in PHP ) in order to notify the client. That is, an event is triggered and directed to my program that is installed on the client’s computer, and the program somehow alerts the event (as playing a sound). The event this would be started by a server-side language, in case PHP.

  • 1

    @Denercarvalho There would be no way I could do everything in PHP, since to send something to the client’s browser, it needs to order, so I thought of creating a program that stays on his computer (written in Pascal, IDE Delphi) in order to make the idea work, where the trigger (event trigger) was initialized by PHP.

  • 2

    Take a look at this question see if this is what you need http://answall.com/questions/2101/notifies%C3%A7%C3%B5es-de-desktop-no-Chrome-com-javascript

  • I did not want it to depend on the browser, even for reasons of compatibility and functionality, and also for the question that the customer would need to be on the page to see the notification. The idea is to have a software installed on the client’s computer, which receives notifications sent by PHP technology in order to process them as programmed, so the software would consume the internet and capture the requests made to it in order to process them and warn the client. It doesn’t have to be a cake recipe, but a path, some notion of how I can take the first step.

  • 1

    Vc can write a desktop application that connects to the database of your web system, could be a solution in integrating the desktop application with the web system.

  • 4

    You can create an app in simple Delphi, which is there on the clock and connected to the database, when there is the change in the bank, fires a callback for the software, or it goes to the bank knows if there have been changes, 15 on 15 me. Without connecting the app in the database, you create an app in Delphi in REST, so you can consume the methods via JS and php, for example when someone on your site sends a question you call the method on the server Rest in Delphi and it warns there on the desktop. Creating a REST service in Delphi is very easy.

  • @Artur_indio Thank you for your answer! It opened new eyes, if you can leave some reference link, it would be even better for me to guide me, but I thank you in advance for the words.

Show 4 more comments

3 answers

10


I suggest the following architecture: - PHP Webservice on the server; - Desktop Application, Delphi, consult the WS server.

For the desktop application, has not much secret, use the Timer, and make the application stays there in the Windows Tray, you can use this component: Qtrayicon.

For server calls, you can use the library Indy.

On the server, in PHP it is simple for you to make a simple Webservice that reads the call via GET and returns whether changes have been made or not, you can return with a JSON, containing the desired answers, something like this:

.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pg=$1

Example of simple WS:

<?php
header("Access-Control-Allow-Origin: *");

$dadosRecebidos = $_GET['pg']);

switch ($_SERVER['REQUEST_METHOD']) {
    case 'GET':
        if ($dadosRecebidos[0] == TESTE){
            echo json_encode(array(MSG_OK, "CONEXAO OK"));
    case ...
...

I also suggest migrating from Delphi to the Lazarus, all open-source!

  • I would like to have time to read and apply this before ending the reward period.. thank you for the reply Celso!

  • 1

    @Alexandrec.Caus, do not worry about the reward... I hope to have helped! And any doubt put there!

  • @Celsomarigojr I was curious about this Lazarus. It is possible to migrate source code from one to another?

  • @Marcosregis, it is possible to migrate from Delphi to Lazarusm even exists within its own IDE a tool for this. Although the conversion is not perfect, it makes it a little easier.

5

Another way to implement this feature, which no one has commented on, is through the use of Webhooks.

The use of "Polling", that is, consulting the server from time to time (via http query or even through direct access to the database) is inefficient in some cases.

If the structure that friend Alexandre presented allows the web application to connect to the client’s terminal, it is possible to create an application in Delphi that is a mini web server that will await connections. When this web server receives some connection, it itself will be able to display the message in some way to the user (in the notification area, for example).

The advantage of webhooks is that the notification will happen in real time, that is, at the exact moment the event occurs in the web application.

An interesting framework that can facilitate the implementation of this resource is the Brook Framework.

4

Currently I use this in a system in the interior where I lived, works basically as you intend.

The web application is responsible for receiving orders or orders made by the customer, and the application in the owner’s Store is 'listening' to the online database all the time, when the customer makes an order/order/quote/doubt I record in a specific field of the bank.

Logic used on the Web:

pedido = 1
encomenda = 2
orcamento = 3
duvida = 4

In the Desktop application (I used a timer = the previous colleague mentioned, however in a much smaller interval, every 30 seconds I run a Select in the bank that is very small not generating any load in the Bank that this Online):

if (resultado sql do campo especificado) = 1 (ou qualquer outro listado acima) then
begin
  //Aqui eu solicito o Som (sim o som, gravei com uma moça de voz suave o aviso)
end;

The customer who ordered me a system like this today has 2 stores and is already opening a third, and previously already asked me for release for use in the third store! His line of work is construction but could be used in any industry!

  • Thanks for the answer Junior, I’ll try to apply before giving the reward the best answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.