Commit 00496074 authored by Corentin Boulanger's avatar Corentin Boulanger
Browse files

Merge branch 'feature/network/refactor-messages-location' into 'int/v2'

Refactored project structure for network messages

See merge request !53
parents 7c355eeb 15570813
......@@ -4,14 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import main.java.client.network.MessageClientController;
import main.java.common.dataModel.Board;
import main.java.common.dataModel.GameHeavy;
import main.java.common.dataModel.GameLight;
import main.java.common.dataModel.Message;
import main.java.common.dataModel.UserLight;
import main.java.common.interfaces.client.IComToData;
import main.java.server.network.messages.serverToClient.GameListMessage;
public class ComToDataClientImpl implements IComToData {
DataCoreClient dataCoreClient;
......
......@@ -2,15 +2,15 @@ package main.java.client.network;
import java.util.UUID;
import main.java.client.network.messages.clientToServer.ChatMessageToServerMessage;
import main.java.client.network.messages.clientToServer.LoginUserToServerMessage;
import main.java.client.network.messages.clientToServer.NewGameToServerMessage;
import main.java.client.network.messages.clientToServer.RequestGameListMessage;
import main.java.common.dataModel.GameLight;
import main.java.common.dataModel.Message;
import main.java.common.dataModel.Move;
import main.java.common.dataModel.UserLight;
import main.java.common.interfaces.client.IDataToCom;
import main.java.common.network.messages.ChatMessageToServerMessage;
import main.java.common.network.messages.LoginUserToServerMessage;
import main.java.common.network.messages.NewGameToServerMessage;
import main.java.common.network.messages.RequestGameListMessage;
public class DataToComClientImpl implements IDataToCom {
......@@ -92,7 +92,7 @@ public class DataToComClientImpl implements IDataToCom {
}
/**
* Resquest the game list to the server
* Request the game list to the server
*/
@Override
public void getServerGameList() {
......
package main.java.client.network;
import java.util.Optional;
import java.util.UUID;
import main.java.client.network.messages.clientToServer.ChatMessageToServerMessage;
import main.java.client.network.messages.clientToServer.LoginUserToServerMessage;
import main.java.client.network.messages.clientToServer.NewGameToServerMessage;
import main.java.client.network.messages.clientToServer.RequestGameListMessage;
import main.java.common.message.MessageMeta;
import main.java.server.network.messages.serverToClient.ChatMessageToClientMessage;
import main.java.server.network.messages.serverToClient.GameListMessage;
import main.java.server.network.messages.serverToClient.NewGameNotificationToClientMessage;
import main.java.server.network.messages.serverToClient.NewUserAddedMessage;
import main.java.server.network.messages.serverToClient.ServerStateOnConnectionMessage;
import main.java.common.network.messages.ChatMessageToClientMessage;
import main.java.common.network.messages.ChatMessageToServerMessage;
import main.java.common.network.messages.GameListMessage;
import main.java.common.network.messages.LoginUserToServerMessage;
import main.java.common.network.messages.MessageMeta;
import main.java.common.network.messages.NewGameNotificationToClientMessage;
import main.java.common.network.messages.NewGameToServerMessage;
import main.java.common.network.messages.NewUserAddedMessage;
import main.java.common.network.messages.RequestGameListMessage;
import main.java.common.network.messages.ServerStateOnConnectionMessage;
/**
* Class handling message sending & receiving
......
package main.java.client.network;
import main.java.common.message.MessageMeta;
import java.lang.reflect.Type;
import main.java.common.network.messages.MessageMeta;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.messaging.simp.stomp.StompCommand;
......@@ -8,8 +9,6 @@ import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter;
import java.lang.reflect.Type;
/**
* WebSocket message handler
*/
......
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.Message;
import main.java.common.message.MessageMeta;
/**
* Message containing a chat message to transfer to the data module to display
* it.
*/
public class ChatMessageToClientMessage extends MessageMeta {
private Message message;
public ChatMessageToClientMessage() {
}
public ChatMessageToClientMessage(Message message) {
}
@Override
public void processData() {
// TODO: Implement
}
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.message.MessageMeta;
import java.util.UUID;
/**
* Message notifying that a user has been disconnected.
*/
public class DisconnectedUserMessage extends MessageMeta {
private UUID playerToDisconnect;
public DisconnectedUserMessage(UUID playerToDisconnect) {
this.playerToDisconnect = playerToDisconnect;
}
public DisconnectedUserMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UUID getPlayerToDisconnect() {
return playerToDisconnect;
}
public void setPlayerToDisconnect(UUID playerToDisconnect) {
this.playerToDisconnect = playerToDisconnect;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.GameLight;
import main.java.common.message.MessageMeta;
/**
* Message notifying that the current game has ended.
*/
public class EndGameSignalToClientMessage extends MessageMeta {
private GameLight endedGameInfo;
public EndGameSignalToClientMessage(GameLight endedGameInfo) {
this.endedGameInfo = endedGameInfo;
}
public EndGameSignalToClientMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public GameLight getEndedGameInfo() {
return endedGameInfo;
}
public void setEndedGameInfo(GameLight endedGameInfo) {
this.endedGameInfo = endedGameInfo;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.message.MessageMeta;
import java.util.UUID;
/**
* Message containing a join request.
*/
public class JoinRequestMessage extends MessageMeta {
private UUID gameID;
private UUID playerAskingID;
public JoinRequestMessage(UUID gameID, UUID playerAskingID) {
this.gameID = gameID;
this.playerAskingID = playerAskingID;
}
public JoinRequestMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UUID getGameID() {
return gameID;
}
public void setGameID(UUID gameID) {
this.gameID = gameID;
}
public UUID getPlayerAskingID() {
return playerAskingID;
}
public void setPlayerAskingID(UUID playerAskingID) {
this.playerAskingID = playerAskingID;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.GameLight;
import main.java.common.dataModel.Move;
import main.java.common.message.MessageMeta;
/**
* Message containing a move to transfer to the data module.
*/
public class MoveToForwardToClientMessage extends MessageMeta {
private GameLight currentGame;
private Move moveToSend;
public MoveToForwardToClientMessage(GameLight currentGame, Move moveToSend) {
this.currentGame = currentGame;
this.moveToSend = moveToSend;
}
public MoveToForwardToClientMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public GameLight getCurrentGame() {
return currentGame;
}
public void setCurrentGame(GameLight currentGame) {
this.currentGame = currentGame;
}
public Move getMoveToSend() {
return moveToSend;
}
public void setMoveToSend(Move moveToSend) {
this.moveToSend = moveToSend;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.client.network.ComCoreClient;
import main.java.common.dataModel.GameLight;
import main.java.common.interfaces.client.IComToData;
import main.java.common.message.MessageMeta;
/**
* Message notifying that a new game has been created.
*/
public class NewGameNotificationToClientMessage extends MessageMeta {
private GameLight newGame;
private ComCoreClient comCoreClient;
private IComToData iComToData;
public NewGameNotificationToClientMessage(GameLight newGame) {
this.newGame = newGame;
}
public NewGameNotificationToClientMessage() {
}
@Override
public void processData() {
}
public GameLight getNewGame() {
return newGame;
}
public void setNewGame(GameLight newGame) {
this.newGame = newGame;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.UserLight;
import main.java.common.message.MessageMeta;
/**
* Message notifying that a new user has been added to the game.
*/
public class NewUserAddedMessage extends MessageMeta {
private UserLight userToAdd;
public NewUserAddedMessage(UserLight userToAdd) {
this.userToAdd = userToAdd;
}
public NewUserAddedMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UserLight getUserToAdd() {
return userToAdd;
}
public void setUserToAdd(UserLight userToAdd) {
this.userToAdd = userToAdd;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.UserLight;
import main.java.common.message.MessageMeta;
/**
* Message containing a player profile received by the client.
*/
public class PlayerProfileReceivedMessage extends MessageMeta {
private UserLight playerProfile;
public PlayerProfileReceivedMessage(UserLight playerProfile) {
this.playerProfile = playerProfile;
}
public PlayerProfileReceivedMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UserLight getPlayerProfile() {
return playerProfile;
}
public void setPlayerProfile(UserLight playerProfile) {
this.playerProfile = playerProfile;
}
}
package main.java.client.network.messages.serverToClient;
import main.java.common.dataModel.UserLight;
import main.java.common.message.MessageMeta;
/**
* Message containing a spectator to add to the game.
*/
public class SpectatorToAddClientMessage extends MessageMeta {
private UserLight playerToAdd;
public SpectatorToAddClientMessage(UserLight playerToAdd) {
this.playerToAdd = playerToAdd;
}
public SpectatorToAddClientMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UserLight getPlayerToAdd() {
return playerToAdd;
}
public void setPlayerToAdd(UserLight playerToAdd) {
this.playerToAdd = playerToAdd;
}
}
package main.java.server.network.messages.serverToClient;
package main.java.common.network.messages;
import main.java.client.network.MessageClientController;
import main.java.common.dataModel.Message;
import main.java.common.message.MessageMeta;
/**
* Message containing a chat message to transfer to a client.
......@@ -17,11 +16,6 @@ public class ChatMessageToClientMessage extends MessageMeta {
public ChatMessageToClientMessage() {
}
@Override
public void processData() {
MessageClientController.getInstance().getComCore().getComToDataClient().receiveChatMessage(this.message);
}
public Message getMessage() {
return message;
}
......
package main.java.client.network.messages.clientToServer;
import main.java.common.dataModel.Message;
import main.java.common.message.MessageMeta;
package main.java.common.network.messages;
import java.util.UUID;
import main.java.common.dataModel.Message;
/**
* Message containing a chat message to send to the server.
*/
......@@ -14,13 +13,11 @@ public class ChatMessageToServerMessage extends MessageMeta {
public ChatMessageToServerMessage(Message chatMessage, UUID gameId) {
super();
this.chatMessage = chatMessage;
this.gameId = gameId;
}
private ChatMessageToServerMessage() {
//NOP
}
public Message getChatMessage() {
......@@ -42,10 +39,5 @@ public class ChatMessageToServerMessage extends MessageMeta {
this.gameId = gameId;
}
@Override
public void processData() {
}
}
//
package main.java.server.network.messages.serverToClient;
import main.java.common.message.MessageMeta;
package main.java.common.network.messages;
import java.util.UUID;
......@@ -18,11 +16,6 @@ public class DisconnectedUserMessage extends MessageMeta {
public DisconnectedUserMessage() {
}
@Override
public void processData() {
// TODO: Implement
}
public UUID getDisconnectedPlayer() {
return disconnectedPlayer;
}
......
package main.java.client.network.messages.clientToServer;
import main.java.common.message.MessageMeta;
package main.java.common.network.messages;
import java.util.UUID;
......@@ -17,11 +15,6 @@ public class DisconnectionRequestMessage extends MessageMeta {
public DisconnectionRequestMessage() {
}
@Override
public void processData() {
}
public UUID getPlayerAskingID() {
return playerAskingID;
}
......
package main.java.server.network.messages.serverToClient;
package main.java.common.network.messages;
import main.java.common.dataModel.GameLight;
import main.java.common.message.MessageMeta;
/**
* Message notifying clients that the game has ended.
......@@ -17,11 +16,6 @@ public class EndGameSignalToClientMessage extends MessageMeta {
public EndGameSignalToClientMessage(String message) {
}
@Override
public void processData() {
// TODO: Implement
}
public GameLight getEndedGameInfo() {
return endedGameInfo;
}
......
package main.java.server.network.messages.serverToClient;
package main.java.common.network.messages;
import java.util.List;
import main.java.common.dataModel.GameLight;
import main.java.common.message.MessageMeta;
public class GameListMessage extends MessageMeta {
......@@ -16,10 +15,6 @@ public class GameListMessage extends MessageMeta {
public GameListMessage() {
}
@Override
public void processData() {
}
public List<GameLight> getGameLights() {
return gameLights;
}
......
package main.java.client.network.messages.serverToClient;
package main.java.common.network.messages;
import main.java.common.dataModel.GameHeavy;
import main.java.common.message.MessageMeta;
/**
* Message containing a game save.
*/
public class GameSaveMessage extends MessageMeta {
private GameHeavy gameSave;
public GameSaveMessage(GameHeavy gameSave) {
......@@ -16,11 +16,6 @@ public class GameSaveMessage extends MessageMeta {
public GameSaveMessage() {
}
@Override
public void processData() {