Skip to content
Michael Kringelhede edited this page Jul 30, 2020 · 2 revisions

The jid-server uses Socket.IO to publish messages about newly created jid codes.

This way jid-ui can update the dashboard every time a jid code is entered without using active polling.

Listening for messages

Messages are received by connecting a socket.io-client to the API server and listening for message types:

import socketIOClient from "socket.io-client";

const socket = socketIOClient('http://jid-server:4000');
socket.on("new jid", data => {
    console.log("Message received: "+JSON.stringify(data));
});

New jid message

When any user saves a new jid code the server publishes the message new jid.

Message body will be similar to:

{
    "jid": "5dk17j",
    "country": "dk",
    "userid": "50a59d04-c3ce-47ef-8246-3db11f93f05d",
    "user": "Hilmar Kampmann"
}
Clone this wiki locally