Commit 48319565 authored by Cynthia SOIMANSOIB's avatar Cynthia SOIMANSOIB
Browse files

Resole issue from V1 : method to send to other players that a new player

is available wasn't merged. It is with this commit.
- Add logic in message controllers (Server and Client to send the new User
to all players and receive it)
parent b4231c51
......@@ -5,6 +5,7 @@ import main.java.client.network.messages.clientToServer.LoginUserToServerMessage
import main.java.client.network.messages.clientToServer.NewGameToServerMessage;
import main.java.common.message.MessageMeta;
import main.java.server.network.messages.serverToClient.ChatMessageToClientMessage;
import main.java.server.network.messages.serverToClient.NewUserAddedMessage;
import main.java.server.network.messages.serverToClient.ServerStateOnConnectionMessage;
import java.util.Optional;
......@@ -82,6 +83,9 @@ public class MessageClientController {
this.comCore.getComToDataClient().receivePlayersnGames(serverStateMessage.getUsersConnected(),
serverStateMessage.getGamesOnline());
break;
case "NewUserAddedMessage":
NewUserAddedMessage newUserMessage = (NewUserAddedMessage) message;
this.comCore.getComToDataClient().addNewUser(newUserMessage.getUserToAdd());
}
}
}
......@@ -93,7 +93,11 @@ public class MessageServerController {
List<UserLight> usersConnected = comCore.getComToData().getListUsers();
ServerStateOnConnectionMessage msg = new ServerStateOnConnectionMessage(loginMessage.getUserToAdd(),
usersConnected, gamesOnline);
MessageServerController.getInstance().sendListsToNewUser(msg);
this.sendListsToNewUser(msg);
//notify others of the fact a new user is available
NewUserAddedMessage userToAdd = new NewUserAddedMessage(loginMessage.getUserToAdd());
this.notifyNewUserAdded(userToAdd);
break;
case "ChatMessageToServerMessage":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment