Server now provides clientid on connection. Client expects this before continuing.

This commit is contained in:
2024-12-10 22:24:45 -05:00
parent c439c42b2f
commit 9345b49f57
6 changed files with 215 additions and 30 deletions

View File

@@ -27,6 +27,7 @@ func init() {
}
type ClientData struct {
Id int
Address string
Name string
Position gamedata.Coordinates
@@ -35,6 +36,7 @@ type ClientData struct {
type Game struct {
name string
blocky *elements.Block
gameId int
//players map[client.Identity]
@@ -56,6 +58,8 @@ func NewGame() *Game {
name: namelist[rand.Intn(len(namelist))],
}
g.clients = make(map[string]ClientData)
g.gameId = g.gameclient.GetIdentity()
go g.gameclient.ReadData(g.HandleServerData)
return g
}
@@ -145,8 +149,8 @@ func (g *Game) HandleServerData(allclients *pb.AllClients) {
for _, client := range allclients.Clients {
//fmt.Println(client.Coordinates.X)
localaddr := g.gameclient.GetLocalAddr()
if client.Address != localaddr {
//localaddr := g.gameclient.GetLocalAddr()
if client.Id != int32(g.gameId) {
update := ClientData{
Address: client.Address,
Name: client.Name,