Quick Guide to bench publish-realtime Command

Hey Frappe community!

I wanted to share a quick guide on using the bench publish-realtime command. This command is incredibly handy for publishing real-time events from the bench, which can be useful for informing users on the desk about important updates or events.

Here’s how it works:

  1. What it Does: The bench publish-realtime command is used to publish real-time events from the bench.

  2. Usage:

    • Usage: bench publish-realtime [OPTIONS] EVENT
    • For example: bench publish-realtime --message "some message" msgprint
    • Replace "some message" with the text you want to send as a real-time message.
  3. How it Works: This command sends the specified message to the msgprint event in Frappe, which is already being listened to. If the socket is working fine, the message will be displayed in Frappe. Otherwise, it won’t.

  4. Custom Events: If you want to send a message to a custom event, make sure you’re listening to that event in the frontend. For example: frappe.realtime.on(event_name, callback).

I find myself referring back to this guide every time I use the command, so I thought I’d share it with you all. Hope you find it helpful too! :sweat_smile:

Feel free to ask if you have any questions or share any tips you have for using this command.

Cheers!

4 Likes