mchess-server/server/server.go

25 lines
435 B
Go

package server
import (
"log"
"net/http"
"github.com/gorilla/websocket"
)
var upgrader = websocket.Upgrader{} // use default options
func SocketHandler(w http.ResponseWriter, r *http.Request) {
log.Println("SocketHandler invoked")
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Print("Error during connection upgrading:", err)
return
}
defer conn.Close()
var game = NewChessGame()
game.handle(conn)
}