Merge branch 'master' of https://github.com/RailboundStudios/bus_infotainment
This commit is contained in:
@@ -39,7 +39,7 @@ class LiveInformation {
|
||||
// By default, load the bus sequences from the assets
|
||||
print("Loading bus sequences from assets");
|
||||
busSequences = BusSequences.fromCSV(
|
||||
await rootBundle.loadString("assets/datasets/bus-blinds.csv"),
|
||||
await rootBundle.loadString("assets/datasets/destinations.json"),
|
||||
await rootBundle.loadString("assets/datasets/bus-sequences.csv")
|
||||
);
|
||||
print("Loaded bus sequences from assets");
|
||||
@@ -49,7 +49,7 @@ class LiveInformation {
|
||||
http.Response response = await http.get(Uri.parse('https://tfl.gov.uk/bus-sequences.csv'));
|
||||
|
||||
busSequences = BusSequences.fromCSV(
|
||||
await rootBundle.loadString("assets/datasets/bus-blinds.csv"),
|
||||
await rootBundle.loadString("assets/datasets/destinations.json"),
|
||||
response.body
|
||||
);
|
||||
|
||||
@@ -294,7 +294,7 @@ class LiveInformation {
|
||||
print("Created room with code $roomCode");
|
||||
}
|
||||
|
||||
Future<void> JoinRoom(String roomCode) async {
|
||||
Future<void> joinRoom(String roomCode) async {
|
||||
print("Joining room with code $roomCode");
|
||||
|
||||
// Disable host mode
|
||||
@@ -375,6 +375,45 @@ class LiveInformation {
|
||||
print("Joined room with code $roomCode");
|
||||
}
|
||||
|
||||
Future<void> leaveRoom() async {
|
||||
|
||||
if (roomCode == null) {
|
||||
throw Exception("Not in a room");
|
||||
}
|
||||
|
||||
if (isHost) {
|
||||
// Access the database
|
||||
final client = auth.client;
|
||||
final databases = appwrite.Databases(client);
|
||||
|
||||
// Remove any existing documents
|
||||
final existingDocuments = await databases.listDocuments(
|
||||
databaseId: "6633e85400036415ab0f",
|
||||
collectionId: "6633e85d0020f52f3771",
|
||||
queries: [
|
||||
appwrite.Query.search("SessionID", roomCode!)
|
||||
]
|
||||
);
|
||||
for (var document in existingDocuments.documents) {
|
||||
await databases.deleteDocument(
|
||||
databaseId: "6633e85400036415ab0f",
|
||||
collectionId: "6633e85d0020f52f3771",
|
||||
documentId: document.$id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
roomCode = null;
|
||||
roomDocumentID = null;
|
||||
isHost = false;
|
||||
|
||||
_keepAliveConnection?.close();
|
||||
_keepAliveConnection = null;
|
||||
|
||||
// Reset stuff
|
||||
setRouteVariant(null);
|
||||
}
|
||||
|
||||
String? lastCommand;
|
||||
Future<void> ServerListener(appwrite.RealtimeMessage response) async {
|
||||
print("Session update");
|
||||
|
||||
@@ -175,7 +175,7 @@ class AnnouncementModule extends InfoModule {
|
||||
bool sendToServer = true
|
||||
}) async {
|
||||
|
||||
if (sendToServer) {
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
|
||||
@@ -230,7 +230,7 @@ class AnnouncementModule extends InfoModule {
|
||||
bool sendToServer = true
|
||||
}) {
|
||||
|
||||
if (sendToServer) {
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
|
||||
@@ -260,7 +260,7 @@ class AnnouncementModule extends InfoModule {
|
||||
bool sendToServer = true
|
||||
}) async {
|
||||
|
||||
if (sendToServer) {
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
|
||||
@@ -324,6 +324,14 @@ class AnnouncementModule extends InfoModule {
|
||||
queue.add(announcement);
|
||||
}
|
||||
|
||||
// Server check
|
||||
bool _shouldSendToServer() {
|
||||
bool condition = liveInformation.roomCode != null;
|
||||
|
||||
print("Should send to server? " + (condition.toString()));
|
||||
return condition;
|
||||
}
|
||||
|
||||
// Constants
|
||||
|
||||
final List<NamedAnnouncementQueueEntry> manualAnnouncements = [
|
||||
|
||||
Reference in New Issue
Block a user