// A client has just requested to connect to the server void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data) { Debug.Log("Connection request from IP " + data.connection.RemoteEndPoint.Address); // Approve connections as long as we are in the login state if (currentState == GameState.Login) { Player newPlayer = new Player(); newPlayer.clientId = data.id; newPlayer.isConnected = false; newPlayer.name = ""; newPlayer.isReady = false; newPlayer.playerClass = 0; newPlayer.teamId = 0; newPlayer.xPosition = 0; newPlayer.yPosition = 0; players.Add(newPlayer); serverNet.ConnectionApproved(data.id); } else { serverNet.ConnectionDenied(data.id); } }
// A client has just requested to connect to the server void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data) { Debug.Log("Connection request from " + data.username); // We either need to approve a connection or deny it if (gameState == GameState.pregame) //Make this bigger for the final game { Player newPlayer = new Player(); newPlayer.clientId = data.id; newPlayer.playerName = data.username; newPlayer.isConnected = false; newPlayer.isReady = false; players.Add(newPlayer); serverNet.ConnectionApproved(data.id); } else { serverNet.ConnectionDenied(data.id); } }
void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data) { Debug.Log("Connection request from " + data.username); // We either need to approve a connection or deny it //if (players.Count < 2) { Player newPlayer = new Player(); newPlayer.clientId = data.id; newPlayer.playerName = data.username; newPlayer.isConnected = false; newPlayer.isReady = false; players.Add(newPlayer); serverNet.ConnectionApproved(data.id); } /* * else * { * serverNet.ConnectionDenied(data.id); * } */ }
// A client has just requested to connect to the server void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data) { Debug.Log("Connection request from " + data.username); serverNet.ConnectionApproved(data.id); }