Skip to content
Snippets Groups Projects
Verified Commit 8cec0fe8 authored by Théo Pirkl's avatar Théo Pirkl :nail_care:
Browse files

Implements events when two people meet

parent 2d18fc83
Branches
No related tags found
1 merge request!21*poof* final version
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);
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment