mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
feat(database): persistence des posts dans une base de données sqlite
This commit is contained in:
parent
80885345fe
commit
69f8d23735
6 changed files with 135 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package rtgre.server;
|
||||
|
||||
import javafx.scene.chart.PieChart;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import rtgre.chat.ChatController;
|
||||
|
|
@ -26,6 +27,7 @@ public class ChatServer {
|
|||
private PostVector postVector;
|
||||
private ContactMap contactMap;
|
||||
private RoomMap roomMap;
|
||||
private DatabaseApi database;
|
||||
|
||||
static {
|
||||
try {
|
||||
|
|
@ -59,6 +61,7 @@ public class ChatServer {
|
|||
contactMap.loadDefaultContacts();
|
||||
roomMap.loadDefaultRooms();
|
||||
roomMap.setLoginSets();
|
||||
postVector.loadPosts();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
|
|
@ -358,6 +361,11 @@ public class ChatServer {
|
|||
sendEventToContact(contactMap.getContact(post.getTo()), postEvent);
|
||||
|
||||
postVector.add(post);
|
||||
|
||||
database = new DatabaseApi();
|
||||
database.addPost(post);
|
||||
database.close();
|
||||
|
||||
LOGGER.info("Fin de doMessage:dm");
|
||||
} else {
|
||||
Post post = new Post(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue