2 ;;; Mudsync --- Live hackable MUD
3 ;;; Copyright © 2017 Christopher Allan Webber <cwebber@dustycloud.org>
5 ;;; This file is part of Mudsync.
7 ;;; Mudsync is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or
10 ;;; (at your option) any later version.
12 ;;; Mudsync is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;;; General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
21 function displayMessage(data) {
22 var new_entry = document.createElement("div");
23 new_entry.setAttribute("class", "stream-entry");
24 var new_text = document.createTextNode(data);
25 new_entry.appendChild(new_text);
26 document.getElementById("stream").appendChild(new_entry);
29 function installWebsocket() {
30 // TODO: Don't hardcode the websocket path; pull it from the DOM
31 var ws = new WebSocket("ws://127.0.0.1:8888");
32 ws.onmessage = function(evt) {
33 displayMessage(evt.data);
35 ws.onopen = function() {
36 console.log("connected");
37 ws.send("Hello, there!");
39 ws.onclose = function () {
40 console.log("closed websocket");
44 window.onload = function () {