How to sent message from Client javascript in realtime using frappe

I can send the message and the client received this message propertly .

from __future__ import unicode_literals
import frappe
from frappe.utils.data import nowtime
import time as tm
@frappe.whitelist()
def update_console():
    for t in range(0,10):
        try:
            print('publishing')   
            msg={
                "payload": {
                    'table':11,
                    'time':str(nowtime()),
                    'product':'Food 101 Special',
                    'qty':5,
                    'uom':'Glass',
                    'user': frappe.session.user
                    }
                }
            frappe.publish_realtime("message", message=msg)
        except Exception as e:
            print(str(e))
        tm.sleep(2)
    return {"time":str(nowtime())}
        #frappe.msgprint("count:"+str(t))

but how a client could send the message back? I am trying like this but not work

const domain = location.protocol + "//" + location.hostname+":9000";
	frappe.provide("frappe.realtime");
	const socket = io(`${domain}`, {
		transports: ["websocket", "polling"],
		path: "/socket.io",
	});
	socket.open();
	window.socket = socket;
	socket.on("update", function (room) {
		console.log(room);
	});
	socket.on("msgprint", (message) => {
		 console.log(`here is the message = ${message}`);
	});
    socket.on("message", (data) => {
		 html =`<tr>
					<td>1</td>
					<td>${data.payload.table}</td>
					<td><img class="mr-3 app-logo" style="width: 24px" src="/assets/erpnext/images/erpnext-logo.svg"></td>
					<td>${data.payload.product}</td>
					<td>${data.payload.qty}</td>
					<td>${data.payload.uom}</td>
					<td>${data.payload.time}</td>
					<td><a href="#" class="btn btn-primary">Done</a></td>
  				</tr>`;
		 $("#order").prepend(html);           
	});
frappe.call({
		method: "smartpos.smartpos.page.bar.bar.update_console",
		callback: function (r) {
			console.log(r.messaeg);
		}
	});
$("#send").click(function(){
		console.log("Hello");
		let msg = {"payload": {
                    "table":11,
                    "time":"sample",
                    "product":"Pho 103 Special",
                    "qty":5,
                    "uom":"Glass",
                    "user": frappe.session.user
                    }
                };
		console.log(frappe.realtime);
	});