Notification on a local network with PostgreSQL

1

I would like to know how I can send a simple notification to users on a local network, send a notification to all other devices with the app connected to the PostgreSQL database ...

    
asked by anonymous 13.09.2016 / 23:45

1 answer

1

In PostgreSQL (Versao >= 9.1) you can make use of LISTEN / NOTIFY to do something like this.

These functions allow clients connected to the bank to receive asynchronous notifications through a specific channel.

For example, clients connected to the database listening to the foobar channel will be able to receive the notifications:

LISTEN foobar;

To notify customers who are listening on channel foobar :

NOTIFY foobar, 'Oi, eu sou uma notificacao!';

If you want a particular client to no longer listen the notification channel foobar :

UNLISTEN foobar;

Reference:

link

I hope I have helped!

    
14.09.2016 / 20:23