Skip to content

Commit b5fd19c

Browse files
committed
grpc: Working demo on Desktop and iOS
1 parent 074b44c commit b5fd19c

File tree

2 files changed

+0
-6
lines changed
  • samples/grpc-kmp-app

2 files changed

+0
-6
lines changed

samples/grpc-kmp-app/composeApp/src/commonMain/kotlin/kotlinx/rpc/sample/App.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ private fun ChatScreen(service: MessageService) {
9595
}
9696
}
9797

98-
// Start/refresh the server stream whenever "me" changes
9998
LaunchedEffect(me) {
10099
messages.clear()
101100
val req = ReceiveMessagesRequest { user = me }
@@ -155,17 +154,14 @@ fun MessageBubble(
155154
) {
156155
val isMe = message.user == me
157156

158-
// bubble colors
159157
val bubbleColor = if (isMe) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.surfaceVariant
160158
val textColor = if (isMe) Color.White else Color.Black
161159

162-
// formatted time
163160
val local = Instant.fromEpochMilliseconds(message.tsMillis)
164161
.toLocalDateTime(TimeZone.currentSystemDefault())
165162
// e.g. "14:05"
166163
val timeText = "${local.hour.toString().padStart(2, '0')}:${local.minute.toString().padStart(2, '0')}"
167164

168-
// alignment: messages from me align to right, others to left
169165
Row(
170166
modifier = modifier
171167
.fillMaxWidth()

samples/grpc-kmp-app/server/src/main/kotlin/kotlinx/rpc/sample/MessageServiceImpl.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class MessageServiceImpl: MessageService {
1919
private val bus = MutableSharedFlow<ChatEntry>(extraBufferCapacity = 64, replay = 0)
2020

2121
override suspend fun SendMessage(message: SendMessageRequest): SendMessageResponse {
22-
// ensure server timestamp / id if you carry those
2322
val entry = ChatEntry {
2423
user = message.user
2524
text = message.text
@@ -30,7 +29,6 @@ class MessageServiceImpl: MessageService {
3029
}
3130

3231
override fun ReceiveMessages(message: ReceiveMessagesRequest): Flow<ChatEntry> {
33-
// broadcast to everyone
3432
return bus.asSharedFlow()
3533
.filter { it.user != message.user }
3634
}

0 commit comments

Comments
 (0)