2

I hope there is someone that can help me. I am writing a software that users can fill in information into a database, but I want to install that same software that I created on multiple computers. When a other user is inserting new information into the software and click save then it must show on his/her computer and at the same time on the other PC's in the network.

I think this is a difficult one to crack, but I hope some one can help me.

Greetings

  • Are you required to do it with delphi? – Ertunç Oct 17 '12 at 09:04
  • Firebird SQL server supports events, so if you make all applications to work with single DB server, then they can receive those events and poll for changes. – Arioch 'The Oct 17 '12 at 13:58
  • @Arioch'The using DB events will lead to business logic in database (stored procedures, triggers need to post events), and still polling is required for the clients which were offline but need to be informed. I recommend to use the database to store data, and to do everything else in the appropriate places. – mjn Oct 17 '12 at 14:56
  • @mjn Well, in FB2 you can use `EXECUTE STATEMENT` to post event from `DML SQL`. But yes, those events are kind of limited. However for basic uses that solves the problem without introducing new entities and failure points. We can add XMPP-like service for online clients, then add NNTP/RSS-like service for offline clients - and end up with three servers to install, three protocols to implement and three connections to care about. Depending on the complexity of task that really can be best option. But "lo-tec", somewhat YAGNI-like one is also to be evaluated. – Arioch 'The Oct 18 '12 at 06:23
  • @mjn speaking of "business logic in database" - that is eternal choice of client/server via 3-tier models. But even your answer seems to not suggest true application server approach. And using different services to store data and update it would be more fragile. – Arioch 'The Oct 18 '12 at 06:26

1 Answers1

1

There are many ways to solve this. I recommend to use a server-side application (installed on the database server system for example) which receives a notification from the inserting app. Then, the server side app will send either a UDP broadcast or use a TCP connection to the clients to notify them.

The clients then just need to listen for server messages in a background thread. The messages will be 'pushed' from the server to the client.

An example which can be used as a starting point is the Indy Telnet client component which has a listener thread for server messages. You do not have to open the client firewall for incoming connections to work this way.

There are also complete messaging solutions available, but maybe they would be to heavyweight for your requirements. If you like, I can provide some links.

I would not recommend

  • database polling (too expensive and unflexible)
  • database events (run in the server process, could block operation or crash)

A standard which can be used for this messaging system is WebSocket. There are commercial and open source Delphi implementations for the client and server side.

mjn
  • 36,362
  • 28
  • 176
  • 378
  • could you possible link some further info on the open source delphi implementations you mention for both client and server side? It would really help! – t1f Mar 17 '17 at 18:18