From 353042ee73e9af218031f5c2dceed9e0d235cc90 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Sun, 7 Apr 2019 19:22:42 +0800 Subject: [PATCH] Fix entry index --- main.go | 28 ++++++++++++++++++---------- static/js/http.js | 8 -------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/main.go b/main.go index 6a43fc20..90ca0ed2 100644 --- a/main.go +++ b/main.go @@ -24,10 +24,14 @@ import ( "encoding/json" ) +const gameboyIndex = "./static/gameboy.html" +const httpIndex = "./static/index_http.html" +const wsIndex = "./static/index_ws.html" + // var webRTC *webrtc.WebRTC var width = 256 var height = 240 -var indexFN string = "./static/gameboy.html" +var indexFN string = wsIndex var service string = "http" type IndexPageData struct { @@ -87,16 +91,20 @@ func main() { } func getWeb(w http.ResponseWriter, r *http.Request) { - tmpl := template.Must(template.ParseFiles(indexFN)) - data := IndexPageData{ - Service: service, + if indexFN != gameboyIndex { + bs, err := ioutil.ReadFile(indexFN) + if err != nil { + log.Fatal(err) + } + w.Write(bs) + } else { + // gameboy index + tmpl := template.Must(template.ParseFiles(indexFN)) + data := IndexPageData{ + Service: service, + } + tmpl.Execute(w, data) } - tmpl.Execute(w, data) - // bs, err := ioutil.ReadFile(index) - // if err != nil { - // log.Fatal(err) - // } - // w.Write(bs) } // initRoom initilize room returns roomID diff --git a/static/js/http.js b/static/js/http.js index d137e956..8b1d2919 100644 --- a/static/js/http.js +++ b/static/js/http.js @@ -9,7 +9,6 @@ function startGame() { $("#loading-screen").show(); $("#menu-screen").fadeOut(); // end clear - // Register with server the session description function postSession(session) { @@ -48,13 +47,6 @@ function startGame() { log("New stream, yay!"); document.getElementById("loading-screen").srcObject = event.streams[0]; - // var el = document.createElement(event.track.kind) - // el.srcObject = event.streams[0] - // el.autoplay = true - // el.width = 800; - // el.height = 600; - // el.poster = new URL("https://orig00.deviantart.net/cdcd/f/2017/276/a/a/october_2nd___gameboy_poltergeist_by_wanyo-dbpdmnd.gif"); - // document.getElementById('remoteVideos').appendChild(el) }