[FIX] fixed showing of players in lobbies when joining and hosting
This commit is contained in:
@@ -146,16 +146,16 @@ namespace Server.Models
|
||||
break;
|
||||
case LobbyIdentifier.HOST:
|
||||
// add new lobby and add this serverclient to it
|
||||
Lobby created = ServerCommunication.INSTANCE.HostForLobby(this.User);
|
||||
int createdLobbyID = ServerCommunication.INSTANCE.HostForLobby(this.User);
|
||||
Debug.WriteLine("[SERVERCLIENT] created lobby");
|
||||
sendMessage(JSONConvert.ConstructLobbyHostCreatedMessage(created));
|
||||
sendMessage(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
|
||||
sendMessage(JSONConvert.ConstructLobbyHostCreatedMessage(createdLobbyID));
|
||||
ServerCommunication.INSTANCE.sendToAll(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
|
||||
break;
|
||||
case LobbyIdentifier.JOIN:
|
||||
int id = JSONConvert.GetLobbyID(payload);
|
||||
ServerCommunication.INSTANCE.JoinLobby(this.User,id);
|
||||
sendMessage(JSONConvert.ConstructLobbyJoinSuccessMessage());
|
||||
sendMessage(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
|
||||
ServerCommunication.INSTANCE.sendToAll(JSONConvert.ConstructLobbyListMessage(ServerCommunication.INSTANCE.lobbies.ToArray()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Server.Models
|
||||
listener = new TcpListener(IPAddress.Any, port);
|
||||
serverClients = new List<ServerClient>();
|
||||
lobbies = new List<Lobby>();
|
||||
Lobby temp = new Lobby(1, 1, 8);
|
||||
Lobby temp = new Lobby(1, 7, 8);
|
||||
lobbies.Add(temp);
|
||||
serverClientsInlobbies = new Dictionary<Lobby, List<ServerClient>>();
|
||||
serverClientsInlobbies.Add(temp, new List<ServerClient>());
|
||||
@@ -150,14 +150,14 @@ namespace Server.Models
|
||||
}
|
||||
}
|
||||
|
||||
public Lobby HostForLobby(User user)
|
||||
public int HostForLobby(User user)
|
||||
{
|
||||
Lobby lobby = new Lobby( lobbies.Count + 1,0, 8);
|
||||
lobbies.Add(lobby);
|
||||
serverClientsInlobbies.Add(lobby, new List<ServerClient>());
|
||||
user.Host = true;
|
||||
AddToLobby(lobby, user);
|
||||
return lobby;
|
||||
return lobby.ID;
|
||||
}
|
||||
|
||||
public void JoinLobby(User user, int id)
|
||||
|
||||
Reference in New Issue
Block a user