Socketio is available in desk view. Any time frappe.publish_realtime()
is called on server it emits js to client
e.g. Can be used for showing a pop-up to a logged in desk user when REST endpoint is accessed.
if not agent_number_processed:
return ""
agents = frappe.get_all("User", fields=['name'], filters={"role": "Awfis Ops User", "phone": agent_number_processed})
if len(agents) > 0:
return agents[0]["name"] #Return the name of the first agent.
else:
return ""
#from frappe.core.notifications import get_notification_config
def awfis_notification_filter():
return {
"for_doctype": {
"Communication": {"status": ["in", ('Linked', 'Open')], "communication_type": "Communication"}
}
}
@frappe.whitelist()
def generate_key_knowlarity():
To enable this on any web page, the page should contain following lines for appropriate library to be used :
frappe.require("assets/frappe/js/lib/socket.io.min.js");
frappe.require("assets/frappe/js/frappe/socketio_client.js");
if (window.dev_server) {
frappe.boot.socketio_port = '9000' //use socketio port shown when bench starts
}
frappe.socket.init();
on the server’s bench console
enter
frappe.publish_realtime(event='msgprint', message='Hello Socketio', user='Guest')
if event='eval_js'
instead of event='msgprint'
the message
argument will be eval()
as js, e.g Following code will have same effect like the previous popup.
frappe.publish_realtime(event='eval_js', message='frappe.msgprint("Hello Socketio");', user='Guest')
16 Likes
I tried this but it only works in production. I have also noticed that the ListView in desk doesn’t auto refresh when a new doctype is posted while in development, but no issue in production. Could this be related?
Is it possible to run javascript method using socket.io ?
if event='eval_js'
instead of event='msgprint'
it’ll run the JavaScript available on client.
try this, It works on development mode.
Dear all, I am creating new print format of sales invoice to print amount in barcode font. Which font name will be given to print it in barcode image? I want to ask you that barcode font is available in the installed package of virtual image?
–
Note:
If you are posting an issue,
We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
Paste your code at http…
Use Developer forum for further discussion
3 Likes