diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-18 00:06:57 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-18 00:06:57 (GMT) |
commit | e9c3f339f4992e9474fc8f9f95ae5e1d21aeb6c5 (patch) | |
tree | 48726f818db905735609e488130ff1b69f84a2c9 | |
parent | 4bdae89134ad99c62a01d1ccd96addef3f53a079 (diff) |
fixed routing, added test for ntp
-rw-r--r-- | src/helsinki.at/rhrdtime/rhrdtime.go | 6 | ||||
-rw-r--r-- | test/index.html | 32 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/helsinki.at/rhrdtime/rhrdtime.go b/src/helsinki.at/rhrdtime/rhrdtime.go index 806e64e..af51902 100644 --- a/src/helsinki.at/rhrdtime/rhrdtime.go +++ b/src/helsinki.at/rhrdtime/rhrdtime.go @@ -180,9 +180,9 @@ func RunMartini(ps *pubsub.PubSub, addr string) { m.Get("/time", func(w http.ResponseWriter, r *http.Request) { handleTimeUpdateClient(w, r, ps) }) - // m.Get("/ntp", func(w http.ResponseWriter, r *http.Request) { - // handleTimeUpdateClient(w, r, ps) - // }) + m.Get("/ntp", func(w http.ResponseWriter, r *http.Request) { + handleNTPClient(w, r, ps) + }) m.RunOnAddr(addr) } diff --git a/test/index.html b/test/index.html index 41d0a3a..031b458 100644 --- a/test/index.html +++ b/test/index.html @@ -6,7 +6,7 @@ background-color: #555; } - #timedata { + div.data { background-color: white; border: 1px solid; padding: 1em; @@ -15,12 +15,30 @@ </style> <script src="jquery.min.js"></script> <script type="text/javascript"> + function NTP() { + this.sock = new WebSocket("ws://localhost:3000/ntp"); + this.sock.onmessage = function (event) { + $('#timedata').text(event.data); + } + + this.sock.onmessage = function (event) { + $('#ntpdata').text(event.data); + } + + this.update = function() { + this.sock.send(JSON.stringify({ t1: (+new Date()), t2: 0, t3: 0, t4: 0, tz_offset: 0, week: 0 })); + } + } + function init() { - var sock = new WebSocket("ws://localhost:3000/time"); + var tusock = new WebSocket("ws://localhost:3000/time"); - sock.onmessage = function (event) { - $('#timedata').text(event.data); + tusock.onmessage = function (event) { + $('#tudata').text(event.data); } + + ntp = new NTP(); + setInterval(ntp.update.bind(ntp), 1000); } </script> </head> @@ -28,7 +46,11 @@ <h1>Radio Helsinki Rivendell Time:</h1> - <div id="timedata"></div> + <div id="tudata" class="data"></div> + + <h1>Radio Helsinki Rivendell NTP:</h1> + + <div id="ntpdata" class="data"></div> </body> </html> |