-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d945643
commit b1bceef
Showing
7 changed files
with
47 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...n/kotlin/de/tum/informatics/www1/artemis/native_app/core/websocket/impl/WebsocketTopic.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.websocket.impl | ||
|
||
object WebsocketTopic { | ||
|
||
/** | ||
* Returns the topic for conversation updates for a course-wide conversation. | ||
*/ | ||
fun getCourseWideConversationUpdateTopic(courseId: Long): String { | ||
return "/topic/metis/courses/$courseId" | ||
} | ||
|
||
/** | ||
* Returns the topic for conversation updates for a non-course-wide conversation. | ||
*/ | ||
fun getNormalConversationUpdateTopic(userId: Long): String { | ||
return "/topic/user/$userId/notifications/conversations" | ||
} | ||
|
||
/** | ||
* Returns the topic for conversation meta updates. This includes channel creation, deletion, | ||
* and updates (like changing the channel name). | ||
*/ | ||
fun getConversationMetaUpdateTopic(courseId: Long, userId: Long): String { | ||
return "/user/topic/metis/courses/$courseId/conversations/user/$userId" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...rtemis/native_app/feature/metis/shared/service/network/ConversationWebsocketExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.shared.service.network | ||
|
||
import de.tum.informatics.www1.artemis.native_app.core.websocket.WebsocketProvider | ||
import de.tum.informatics.www1.artemis.native_app.core.websocket.impl.WebsocketTopic | ||
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.ConversationWebsocketDto | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
fun WebsocketProvider.subscribeToConversationUpdates(userId: Long, courseId: Long): Flow<ConversationWebsocketDto> { | ||
val topic = "/user/topic/metis/courses/$courseId/conversations/user/$userId" | ||
val topic = WebsocketTopic.getConversationMetaUpdateTopic(courseId, userId) | ||
|
||
return subscribeMessage(topic, ConversationWebsocketDto.serializer()) | ||
} |