Server now provides clientid on connection. Client expects this before continuing.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user