Alert message via Schedule

Hi All,
I have managed to create a @whitelist script in my APP that will check for check_in timout in case of rooms booked… and cancel the reservation. Now my point goes to how can I send an ALERT to all users logged or to the DESK if the user is idle about the room that needs to be free or cleaning to be done?

Is there an event where I can add my code resulted from the task run on Schedule?
For example one room was booked for 2/3 hours and passed the time an ALERT should be shown to the user of the extra time … tried frappe.print and frappe.msgprint but they only send to the console not to the user like the ALERT.

use sockets

frappe.publish_realtime('msgprint', 'message', user=user)
1 Like

@rmehta thanks for the tip … just one more question is how to use sockets … should I enable on the config or on the nginx?
Also when tried is said Global name ‘user’ is not defined!

Just tried and no message or alert is shown on the screen … I had added on user=frappe.session.user
now will this get all the users logged and send to them (would be great) ?

@rmehta sorry but the frappe.publish_realtime not working … I have added this to my py like this
frappe.publish_realtime(‘msgprint’, “QUARTO XXXX Cancelada por mais de XXX horas”, user=frappe.session.user)

Anyone has tried this frappe.publish_realtime and got it working??

Facing the same problem.

Raised an issue.

frappe.publish_realtime is working on production setup. It is not working on bench start

error in bench start

20:48:10 socketio.1       | listening on *: 9001
20:48:12 socketio.1       | { Error: connect ECONNREFUSED
20:48:12 socketio.1       |     at Object.exports._errnoException (util.js:1012:11)
20:48:12 socketio.1       |     at exports._exceptionWithHostPort (util.js:1035:20)
20:48:12 socketio.1       |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
20:48:12 socketio.1       |   code: 'ECONNREFUSED',
20:48:12 socketio.1       |   errno: 'ECONNREFUSED',
20:48:12 socketio.1       |   syscall: 'connect',
20:48:12 socketio.1       |   address: '',
20:48:12 socketio.1       |   port: 8000,
20:48:12 socketio.1       |   response: undefined }

Browser Console after bench start net::ERR_CONNECTION_REFUSED

If the same development setup is changed to production with frappe-bench.conf files and starting services, frappe.publish_realtime starts working.

1 Like

Where to put this socket code? Please help us with this.

Use Case: We generally file tenders for projects, we created a custom doctype named Tender with all the necessary fields. For this we need popup alerting system which alerts the users 4-5 days before the tendering date.

For example: Tender last date is 15-01-2018 and we set alerts on 10-01-2018, which should be shown as a popup alert.