import { reactive, ref } from "vue";

export function connect(endpoint, callback){
  const socket = new WebSocket(endpoint);

  // Connection opened
  socket.addEventListener("open", (event) => {
    console.log("Connection open");
  });

  // Listen for messages
  socket.addEventListener("message", callback);

  window.onbeforeunload = function() {
      socket.close();
  };
}

export let autodartsState = reactive({
  status: null
})