|
|
@ -5,14 +5,49 @@ import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gorilla/websocket" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Health struct { |
|
|
|
|
|
|
|
Health string `json:"Health"` |
|
|
|
|
|
|
|
Lobbies int `json:"Lobbies"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func health(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func index(w http.ResponseWriter, r *http.Request) { |
|
|
|
func index(w http.ResponseWriter, r *http.Request) { |
|
|
|
fmt.Fprintf(w, "index") |
|
|
|
fmt.Fprintf(w, "index") |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func wsEndpoint(w http.ResponseWriter, r *http.Request) { |
|
|
|
func wsEndpoint(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
var upgrader = websocket.Upgrader{ |
|
|
|
|
|
|
|
ReadBufferSize: 1024, |
|
|
|
|
|
|
|
WriteBufferSize: 1024, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn, err := upgrader.Upgrade(w, r, nil) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Println(r.RemoteAddr) |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
messageType, p, err := conn.ReadMessage() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if err := conn.WriteMessage(messageType, p); err != nil { |
|
|
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(w, "hello") |
|
|
|
fmt.Fprintf(w, "hello") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|