I am trying to send realtime events just after the job is completed or after a function call is done. But in the client side it doesn’t display the alert which is mentioned over event_notify.js. I also un-commented hooks.py:
app_include_js = "/assets/my_app/js/event_notify.js"
But still I am not able to receive any alert. This issue was also raised in :
realtime-not-working-queues-2021
Some code for refrences:
custom function code:
frappe.enqueue(
method="my_app.media-queues.tasks_pipe.language_detection",
queue="default",
audio_filename= audio_filename,
processed_docname=processed_doc.name,
video_filename=video_filename,
user=frappe.session.user
)
def language_detection(audio_filename: str, processed_docname: str, video_filename: str, user: str):
print("user: ", user)
print("before lang detection function call ")
src_language=lang_detection(audio_filename, processed_docname)
print("source language after lang detection is : ", src_language)
print("before publishing real time event for lang detection")
frappe.publish_realtime(
event="language_detection_completed",
message={"text":f"source language detected : {src_language}"},
user=user
)
public/js/event_notify.js:
frappe.ready(()=>{
frappe.realtime.on("language_detection_completed", (data) => {
frappe.show_alert({
message: data.text,
indicator: "green"
})
})
frappe.realtime.on("hindi_dubbing_completed", (data) => {
frappe.show_alert({
message: data.text,
indicator: "green"
}, 5)
})
})