This file contains hidden or 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
| data class Player( | |
| val userName: String, | |
| var socket: WebSocketSession, | |
| val clientId: String, | |
| ) |
This file contains hidden or 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
| fun Application.configureRouting() { | |
| routing { | |
| gameSocketRoute() | |
| } | |
| } |
This file contains hidden or 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
| fun Route.gameSocketRoute() { | |
| route("/v1/game") { | |
| try { | |
| webSocket { | |
| } | |
| } catch (e: Exception) { | |
| e.printStackTrace() | |
| } finally { | |
| // Handle Socket disconnect |
This file contains hidden or 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
| fun main() { | |
| embeddedServer(Netty, port = port, host = "0.0.0.0") { | |
| install(CallLogging) | |
| configureSockets() | |
| configureRouting() | |
| configureSerialization() | |
| configureSession() | |
| }.start(wait = true) | |
| } |
This file contains hidden or 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
| fun Application.configureSockets() { | |
| install(WebSockets) { | |
| pingPeriod = Duration.ofSeconds(15) | |
| timeout = Duration.ofSeconds(15) | |
| maxFrameSize = Long.MAX_VALUE | |
| masking = false | |
| } | |
| } |
This file contains hidden or 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
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
| val ktor_version: String by project | |
| val kotlin_version: String by project | |
| val logback_version: String by project | |
| plugins { | |
| application | |
| kotlin("jvm") version "1.5.31" | |
| } |
This file contains hidden or 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
| ktor_version=1.6.4 | |
| kotlin_version=1.5.31 | |
| logback_version=1.2.6 | |
| kotlin.code.style=official | |
| koin_version=3.1.2 |
This file contains hidden or 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
| @AndroidEntryPoint | |
| class MainActivity : AppCompatActivity() { | |
| private lateinit var saveDataButton: Button | |
| private lateinit var clearDataButton: Button | |
| private lateinit var getDataButton: Button | |
| private lateinit var inputName: EditText | |
| private lateinit var inputAge: EditText | |
| private val viewModel by viewModels<DataViewModel>() |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="@color/white" | |
| tools:context=".presentation.activity.MainActivity"> | |
| <LinearLayout |
This file contains hidden or 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
| @Module | |
| @InstallIn(SingletonComponent::class) | |
| object AppModule { | |
| @Singleton | |
| @Provides | |
| fun provideDataStoreRepository( | |
| @ApplicationContext app: Context | |
| ): DataStoreRepository = DataStoreRepositoryImpl(app) |