Commit e888d819 authored by Corentin-Boulanger's avatar Corentin-Boulanger Committed by alexandre.ducarne
Browse files

Implement sending chat message from client to server

parent 0428bdff
package main.java.client.network;
import java.sql.Timestamp;
import java.util.UUID;
import main.java.client.network.messages.clientToServer.ChatMessageToServerMessage;
import main.java.client.network.messages.clientToServer.LoginUserToServerMessage;
import main.java.common.dataModel.GameLight;
import main.java.common.dataModel.Move;
......@@ -51,8 +55,8 @@ public class DataToComClientImpl implements IDataToCom {
@Override
public void sendChatMessage(String message, Timestamp time, UUID playerID, UUID gameID) {
// TODO Auto-generated method stub
ChatMessageToServerMessage msg = new ChatMessageToServerMessage(message, time, playerID, gameID);
comCoreClient.getMessageClientController().sendChatMessageToServer(msg);
}
@Override
......
package main.java.client.network;
import main.java.client.network.messages.clientToServer.ChatMessageToServerMessage;
import main.java.client.network.messages.clientToServer.LoginUserToServerMessage;
import java.util.Optional;
......@@ -46,4 +47,14 @@ public class MessageClientController {
void sendNewGameAvailableToServer(NewGameToServerMessage message) {
wsHandler.sendMessage(message);
}
/**
* Send a ChatMessageToServerMessage to the server
*
* @param message the message to send
*/
public void sendChatMessageToServer(ChatMessageToServerMessage message) {
// TODO send to the correct game by retrieving message.gameID
wsHandler.sendMessage(message);
}
}
package main.java.client.network.messages.clientToServer;
import main.java.common.message.MessageMeta;
import java.sql.Timestamp;
import java.util.UUID;
import main.java.common.message.MessageMeta;
import main.java.server.network.ComCoreServer;
import main.java.server.network.MessageServerController;
/**
* Message containing a chat message to send to the server.
*/
......@@ -26,7 +28,8 @@ public class ChatMessageToServerMessage extends MessageMeta {
@Override
public void processData() {
// TODO: Implement
ComCoreServer comCore = MessageServerController.getInstance().getComCore();
comCore.getComToData().receiveNewChatMessage(message, time, playerID, gameID);
}
public String getMessage() {
......
......@@ -47,6 +47,8 @@ public interface IDataToCom {
*
* @param message : the message
* @param time : the timestamp when the message was written
* @param playerID : the ID of the player sending the message
* @param gameID : the game in which the message was sent
*/
void sendChatMessage(String message, Timestamp time, UUID playerID, UUID gameID);
......
......@@ -3,6 +3,9 @@ package main.java.server.data;
import main.java.common.dataModel.*;
import main.java.common.interfaces.server.IComToData;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.UUID;
import java.sql.Array;
import java.sql.Timestamp;
import java.util.*;
......
Supports Markdown
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