Chat with mercure

Hello,

I’m trying to use what module in live mode with mercure (https://mercure.rocks).

I made a custom Backend (Working with Server of UI Complex Widgets, Chat Webix Docs) to send all datas to the server with Ajax . No problem with that.

I connect to my mercure server in the init function with en EventSource. I receive correctly messages from the server but I don’t know how to update the view.

I can see a fire function in the webix chat.js code :

switch (n.action) {
							case "result":
								e.result(n.body, []);
								break;
							case "event":
								e.fire(n.body.name, n.body.value);
								break;
							case "start":
								t._mode = 3, t._send(), t._resubscribe();
								break;
							default:
								e.onError(n.data)
						}

I believe the best way is touse this function but I don’t know how to access this function from the ChatView

Any idea ?

Thanks in advance

I found my answer.

The Backend service uses the node “remote-client” package. This package is used to make the Websocket with the server.

I couldn’t find a clean way to configure a custom remote client to use Mercure instead of Websocket. The only solution I found is to make a custom Backend service that doesn’t extends the default Backend.

It’s basically the same but I replace

import { Client } from "remote-client";

by

import {Client} from "./chatMercureClient";

Please let me know if anyone has a cleaner way to do it.