Compare commits

..

No commits in common. 'b26a6cf65ecf9998a8ea4e2e16a8d82aaade570b' and 'd42b596bf082012d4164d7766ddb3ef24b0b25ac' have entirely different histories.

  1. 13
      internal/gameServer/gameServer.go
  2. 7
      internal/player/player.go
  3. 13
      internal/room/room.go
  4. 11
      internal/server/server.go

@ -2,7 +2,6 @@ package gameServer
import (
"daydev.org/shipsgs/internal/config"
"daydev.org/shipsgs/internal/player"
"daydev.org/shipsgs/internal/utils"
)
@ -15,14 +14,6 @@ type GameServer struct {
maxPlayers int
currentPlayers int
// Channel to register players and their connection
join chan *player.Player
// Storing connected Players
playerConns map[*player.Player]bool
// Channel to un register players
}
func (m *GameServer) Init(logger *utils.Logger, config *config.S_Config) {
@ -38,11 +29,7 @@ func (m *GameServer) Init(logger *utils.Logger, config *config.S_Config) {
}
func (m *GameServer) Update() {
//p := <-m.join
// If room doesnt exist, spawn it, name it
//Add a player to a room
//
}
func (m *GameServer) Scheduled1S() {

@ -1,14 +1,9 @@
package player
import "github.com/gorilla/websocket"
type Player struct {
Name string `json:"Name"`
Password string `json:"Password"`
//Connection WS variable TODO
Conn *websocket.Conn
AuthString string `json:"AuthString"`
Level string `json:"Level"` // hidden from user, for balancing purposes
@ -19,6 +14,4 @@ type Player struct {
Won int `json:"Won"`
Lost int `json:"Lost"`
WinRate int `json:"WinRate"`
Health int `json:"Health"`
}

@ -1,13 +0,0 @@
package room
import "daydev.org/shipsgs/internal/player"
type Room struct {
Name string `json:"Name"`
//Players
players map[*player.Player]bool
//Room state
}

@ -6,7 +6,6 @@ import (
"log"
"net/http"
"daydev.org/shipsgs/internal/player"
"github.com/gorilla/websocket"
)
@ -28,9 +27,6 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true // DANGEROUS. USING FOR DEV PURPOSES ONLY
},
}
conn, err := upgrader.Upgrade(w, r, nil)
@ -40,12 +36,6 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
return
}
player := player.Player{
Conn: conn,
}
log.Println(r.RemoteAddr)
for {
messageType, p, err := conn.ReadMessage()
if err != nil {
@ -58,6 +48,7 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
}
}
fmt.Fprintf(w, "hello")
}
func setupRoutes() {

Loading…
Cancel
Save