diff --git a/apps/giga-wear/backend/src/main/kotlin/ru/shadowsparky/gigawear/backend/presentation/ChatRouting.kt b/apps/giga-wear/backend/src/main/kotlin/ru/shadowsparky/gigawear/backend/presentation/ChatRouting.kt index 69b0444..7f4a908 100644 --- a/apps/giga-wear/backend/src/main/kotlin/ru/shadowsparky/gigawear/backend/presentation/ChatRouting.kt +++ b/apps/giga-wear/backend/src/main/kotlin/ru/shadowsparky/gigawear/backend/presentation/ChatRouting.kt @@ -14,4 +14,5 @@ fun Routing.setupChat(useCase: ProcessUserMessageUseCase) { val message = call.receive().copy(timestamp = System.currentTimeMillis()) call.respond(useCase.execute(message, MOCK_USER_ID)) } + } diff --git a/apps/giga-wear/client/build.gradle.kts b/apps/giga-wear/client/build.gradle.kts index fc299dd..46e62f5 100644 --- a/apps/giga-wear/client/build.gradle.kts +++ b/apps/giga-wear/client/build.gradle.kts @@ -29,6 +29,8 @@ dependencies { implementation(project(":libs:ui")) implementation(project(":libs:http-client")) implementation(project(":libs:base")) + implementation(project(":feature:chat:chat-common")) + implementation(libs.activity.compose) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.material3) diff --git a/apps/giga-wear/client/src/debug/AndroidManifest.xml b/apps/giga-wear/client/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..3d0c28e --- /dev/null +++ b/apps/giga-wear/client/src/debug/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/apps/giga-wear/client/src/debug/res/xml/network_security_config.xml b/apps/giga-wear/client/src/debug/res/xml/network_security_config.xml new file mode 100644 index 0000000..24579b1 --- /dev/null +++ b/apps/giga-wear/client/src/debug/res/xml/network_security_config.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/apps/giga-wear/client/src/main/AndroidManifest.xml b/apps/giga-wear/client/src/main/AndroidManifest.xml index 488d441..e865fb4 100644 --- a/apps/giga-wear/client/src/main/AndroidManifest.xml +++ b/apps/giga-wear/client/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - + @@ -11,7 +12,9 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@android:style/Theme.DeviceDefault"> + android:networkSecurityConfig="@xml/network_security_config" + android:theme="@android:style/Theme.DeviceDefault" + tools:ignore="WatchFaceFormatDeclaresHasNoCode"> = emptyList() + override suspend fun send(message: Message): Message { + return httpClient.post("http://192.168.0.76:8181/chat") { + setBody(message) + }.body() + } +} diff --git a/apps/giga-wear/client/src/main/res/xml/network_security_config.xml b/apps/giga-wear/client/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000..bcf9695 --- /dev/null +++ b/apps/giga-wear/client/src/main/res/xml/network_security_config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/apps/vbox/backend/src/main/kotlin/ru/shadowsparky/vbox/backend/data/chat/BackendChatRepository.kt b/apps/vbox/backend/src/main/kotlin/ru/shadowsparky/vbox/backend/data/chat/BackendChatRepository.kt index cbe00ca..4001646 100644 --- a/apps/vbox/backend/src/main/kotlin/ru/shadowsparky/vbox/backend/data/chat/BackendChatRepository.kt +++ b/apps/vbox/backend/src/main/kotlin/ru/shadowsparky/vbox/backend/data/chat/BackendChatRepository.kt @@ -22,7 +22,7 @@ class BackendChatRepository( return history.sortedBy { it.timestamp } } - override suspend fun send(message: Message) { - storage.insert(userId, message) + override suspend fun send(message: Message): Message { + error("Must be not called") } } diff --git a/apps/vbox/client/shared/src/commonMain/kotlin/ru/shadowsparky/vbox/shared/data/chat/RemoteChatRepository.kt b/apps/vbox/client/shared/src/commonMain/kotlin/ru/shadowsparky/vbox/shared/data/chat/RemoteChatRepository.kt index c98e75e..fc0d96a 100644 --- a/apps/vbox/client/shared/src/commonMain/kotlin/ru/shadowsparky/vbox/shared/data/chat/RemoteChatRepository.kt +++ b/apps/vbox/client/shared/src/commonMain/kotlin/ru/shadowsparky/vbox/shared/data/chat/RemoteChatRepository.kt @@ -33,8 +33,8 @@ class RemoteChatRepository( ).content.asReversed() } - override suspend fun send(message: Message) { - httpClient.post { + override suspend fun send(message: Message): Message { + return httpClient.post { setBody(message) serverConfigurationRepository.getServerConfiguration().apply( this, diff --git a/feature/chat/chat-common/src/commonMain/kotlin/ru/shadowsparky/chat/domain/ChatRepository.kt b/feature/chat/chat-common/src/commonMain/kotlin/ru/shadowsparky/chat/domain/ChatRepository.kt index a7bc21a..b62ab49 100644 --- a/feature/chat/chat-common/src/commonMain/kotlin/ru/shadowsparky/chat/domain/ChatRepository.kt +++ b/feature/chat/chat-common/src/commonMain/kotlin/ru/shadowsparky/chat/domain/ChatRepository.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable interface ChatRepository { suspend fun query(afterId: Long?): List - suspend fun send(message: Message) + suspend fun send(message: Message): Message companion object { const val ARG_AFTER_ID = "after_id"