Skip to content

Commit

Permalink
feat: 현재 참여자 조회 api
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 27, 2024
1 parent 60fd8ff commit 96aab64
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.hero.alignlab.domain.dev.resource
import com.hero.alignlab.config.swagger.SwaggerTag.DEV_TAG
import com.hero.alignlab.domain.auth.model.DevAuthUser
import com.hero.alignlab.domain.dev.application.DevWebsocketService
import com.hero.alignlab.ws.handler.ReactiveGroupUserWebSocketHandler
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
Expand All @@ -14,7 +15,8 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE])
class DevWebsocketResource(
private val devWebsocketService: DevWebsocketService
private val devWebsocketService: DevWebsocketService,
private val reactiveGroupUserWebSocketHandler: ReactiveGroupUserWebSocketHandler
) {
@Operation(summary = "[DEV] websocket connection closed")
@PostMapping("/api/dev/v1/websocket/connection-closed")
Expand All @@ -23,4 +25,10 @@ class DevWebsocketResource(
) {
devWebsocketService.forceCloseAllWebSocketSessions()
}

@Operation(summary = "[DEV] 현재 참여자 정보 조회")
@PostMapping("/api/dev/v1/websocket/group-users")
suspend fun getGroupUsers(
dev: DevAuthUser,
) = reactiveGroupUserWebSocketHandler.getWsGroupUsers()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.hero.alignlab.ws.handler
import com.hero.alignlab.domain.auth.application.AuthFacade
import com.hero.alignlab.domain.group.application.GroupUserService
import com.hero.alignlab.ws.model.GroupUserUriContext
import com.hero.alignlab.ws.model.WsGroupUserModel
import com.hero.alignlab.ws.service.GroupUserWsFacade
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -149,4 +150,11 @@ class ReactiveGroupUserWebSocketHandler(
/** Websocket Session Release */
groupUserByMap.clear()
}

fun getWsGroupUsers(): List<WsGroupUserModel> {
return groupUserByMap.map {
WsGroupUserModel(it.key, it.value.keys)
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.hero.alignlab.ws.model

data class WsGroupUserModel(
val groupId: Long,
val uids: Set<Long>
)

0 comments on commit 96aab64

Please sign in to comment.