File tree Expand file tree Collapse file tree 2 files changed +0
-6
lines changed
composeApp/src/commonMain/kotlin/kotlinx/rpc/sample
server/src/main/kotlin/kotlinx/rpc/sample Expand file tree Collapse file tree 2 files changed +0
-6
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ private fun ChatScreen(service: MessageService) {
95
95
}
96
96
}
97
97
98
- // Start/refresh the server stream whenever "me" changes
99
98
LaunchedEffect (me) {
100
99
messages.clear()
101
100
val req = ReceiveMessagesRequest { user = me }
@@ -155,17 +154,14 @@ fun MessageBubble(
155
154
) {
156
155
val isMe = message.user == me
157
156
158
- // bubble colors
159
157
val bubbleColor = if (isMe) MaterialTheme .colorScheme.primary else MaterialTheme .colorScheme.surfaceVariant
160
158
val textColor = if (isMe) Color .White else Color .Black
161
159
162
- // formatted time
163
160
val local = Instant .fromEpochMilliseconds(message.tsMillis)
164
161
.toLocalDateTime(TimeZone .currentSystemDefault())
165
162
// e.g. "14:05"
166
163
val timeText = " ${local.hour.toString().padStart(2 , ' 0' )} :${local.minute.toString().padStart(2 , ' 0' )} "
167
164
168
- // alignment: messages from me align to right, others to left
169
165
Row (
170
166
modifier = modifier
171
167
.fillMaxWidth()
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ class MessageServiceImpl: MessageService {
19
19
private val bus = MutableSharedFlow <ChatEntry >(extraBufferCapacity = 64 , replay = 0 )
20
20
21
21
override suspend fun SendMessage (message : SendMessageRequest ): SendMessageResponse {
22
- // ensure server timestamp / id if you carry those
23
22
val entry = ChatEntry {
24
23
user = message.user
25
24
text = message.text
@@ -30,7 +29,6 @@ class MessageServiceImpl: MessageService {
30
29
}
31
30
32
31
override fun ReceiveMessages (message : ReceiveMessagesRequest ): Flow <ChatEntry > {
33
- // broadcast to everyone
34
32
return bus.asSharedFlow()
35
33
.filter { it.user != message.user }
36
34
}
You can’t perform that action at this time.
0 commit comments