const wsUri = "ws://127.0.0.1/";

const websocket = new WebSocket(wsUri);

websocket.onopen = function (event) {
  console.log("WebSocket is open now.", event);
};

websocket.onmessage = function (event) {
  console.log("WebSocket message received:", event.data);
};

websocket.onclose = function (event) {
  console.log("WebSocket is closed now.", event.reason);
};

websocket.onerror = function (event) {
  console.error("WebSocket error observed:", event);
};