diff --git a/src/main/java/ch/hepia/mq/MessageManager.java b/src/main/java/ch/hepia/mq/MessageManager.java index 877ec3bdf3e5cfb7f1d6ecdcb5127584894360a8..71028397aea465121c0562b895b407364f1e4054 100644 --- a/src/main/java/ch/hepia/mq/MessageManager.java +++ b/src/main/java/ch/hepia/mq/MessageManager.java @@ -1,6 +1,9 @@ package ch.hepia.mq; -import ch.hepia.events.*; +import ch.hepia.events.ChatMessage; +import ch.hepia.events.JoinedJourney; +import ch.hepia.events.LeftJourney; +import ch.hepia.events.Meeting; import java.io.Serializable; import java.util.function.Consumer; @@ -140,8 +143,8 @@ public class MessageManager extends MessageQueue { } /** - * Send a ChatMessage event - * @param event ChatMessage event + * Send a Meeting event + * @param event Meeting event */ public void sendMeeting(Meeting event) { this.sendEvent(Message.Type.Meeting, event); diff --git a/src/main/java/ch/hepia/ui/MainWindowController.java b/src/main/java/ch/hepia/ui/MainWindowController.java index 9c84b94cdff4b420b4b599a566d605e2244dc054..8b1334cb77d68b02c723cc1805d5f8e48cad2d6f 100644 --- a/src/main/java/ch/hepia/ui/MainWindowController.java +++ b/src/main/java/ch/hepia/ui/MainWindowController.java @@ -5,10 +5,7 @@ import ch.hepia.api.transport.*; import ch.hepia.api.weather.WeatherAPI; import ch.hepia.config.AppConfig; import ch.hepia.config.AppContext; -import ch.hepia.events.ChatMessage; -import ch.hepia.events.Event; -import ch.hepia.events.JoinedJourney; -import ch.hepia.events.LeftJourney; +import ch.hepia.events.*; import ch.hepia.models.User; import javafx.animation.TranslateTransition; import javafx.application.Platform; @@ -433,15 +430,7 @@ public class MainWindowController implements Initializable { try { Section commonSection = joinedJourney.getConnection().getInCommonSection(currentJourney); if (!(commonSection.equals(Section.empty()))){ - drawMessage( - String.format( - AppConfig.COMMON_ITINERARY_TEXT, - sender.getName(), - commonSection.getDeparture().getLocation().getName() - ), - AppConfig.JOURNEY_ICON_COMMON_ITINERARY, - AppConfig.COLOR_BLUE_50_OPACITY - ); + app.getMessageManager().sendMeeting(new Meeting(sender, app.getUser().get(), commonSection)); } } catch (ParseException e) { e.printStackTrace(); @@ -461,8 +450,16 @@ public class MainWindowController implements Initializable { }), userFilter::test); app.getMessageManager().conditionalSubscribeMeeting(meeting -> Platform.runLater(() -> { - //Consumer code - }), userFilter::test); + drawMessage( + String.format( + AppConfig.COMMON_ITINERARY_TEXT, + meeting.getPartner().getName(), + meeting.getSection().getDeparture().getLocation().getName() + ), + AppConfig.JOURNEY_ICON_COMMON_ITINERARY, + AppConfig.COLOR_BLUE_50_OPACITY + ); + }), event -> userFilter.test(event) && true); }