6/2/2017 - 12:47 PM

From https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

// Send text to all users through the server
function sendText() {
  // Construct a msg object containing the data the server needs to process the message from the chat client.
  var msg = {
    type: "message",
    text: document.getElementById("text").value,
    id:   clientID,
    date: Date.now()

  // Send the msg object as a JSON-formatted string.
  // Blank the text input element, ready to receive the next line of text from the user.
  document.getElementById("text").value = "";