Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce0203 committed Aug 2, 2023
1 parent 260c404 commit b080688
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions server/src/main/kotlin/application/rooms.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import application.configuration.getPlayer
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.auth.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlinx.uuid.UUID
Expand All @@ -17,14 +18,11 @@ fun Application.configureRooms() {
route("rooms") {
post { call.respond(listRoom()) }
post("create") { call.respond(createRoom(call.getPlayer())) }
post("join/{uuid}") {
call.parameters["uuid"]
post("join") {
//todo
call.respond(HttpStatusCode.OK)
}
post("{uuid}/name") {
call.respond(nameRoom(UUID(call.parameters["uuid"]!!)))
}
post("name") { call.respond(nameRoom(call.receive<UUID>())) }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/commonMain/kotlin/network/ViewedRoom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ suspend fun getViewedRooms() = runCatching {
}.body<List<ViewedRoom>>()
}.apply { this.exceptionOrNull()?.printStackTrace() }.getOrElse { listOf() }

suspend fun joinRoom(uuid: UUID) = sendHttp("rooms/join/$uuid").status
suspend fun joinRoom(uuid: UUID) = sendHttp("rooms/join", uuid).status

suspend fun getRoomName(uuid: UUID) = sendHttp("rooms/$uuid/name").body<String>()
suspend fun getRoomName(uuid: UUID) = sendHttp("rooms/name", uuid).body<String>()

0 comments on commit b080688

Please sign in to comment.