mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(messages): possibilité de modifier ou supprimer un message
This commit is contained in:
parent
cbbb95f6d5
commit
bf1a52f368
8 changed files with 210 additions and 4 deletions
|
|
@ -158,7 +158,7 @@ public class ChatServer {
|
|||
return contactMap;
|
||||
}
|
||||
|
||||
/** Temporaire : connecte daisy pour test */
|
||||
/** Temporaire : connecte pour test */
|
||||
public static void daisyConnect() throws IOException {
|
||||
ChatClient client = new ChatClient("localhost", 2024, null);
|
||||
client.sendAuthEvent(new Contact("daisy", null));
|
||||
|
|
@ -282,12 +282,27 @@ public class ChatServer {
|
|||
doCont(event.getContent());
|
||||
LOGGER.info("Update de contact");
|
||||
return true;
|
||||
} else if (event.getType().equals(Event.POST)) {
|
||||
doPost(event.getContent());
|
||||
LOGGER.info("Post edited");
|
||||
return true;
|
||||
} else {
|
||||
LOGGER.warning("Unhandled event type: " + event.getType());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void doPost(JSONObject content) {
|
||||
database = new DatabaseApi();
|
||||
database.removePost(Post.fromJson(content));
|
||||
database.addPost(Post.fromJson(content));
|
||||
database.close();
|
||||
postVector.removeIf(post -> post.getId().equals(Post.fromJson(content).getId()));
|
||||
postVector.add(Post.fromJson(content));
|
||||
sendEventToAllContacts(new Event(Event.POST, content));
|
||||
LOGGER.info("didpost");
|
||||
}
|
||||
|
||||
private void doCont(JSONObject content) {
|
||||
if (user.isConnected()) {
|
||||
sendEventToAllContacts(new Event("CONT", content));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue