-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/DRAW-157-3' into sandbox
- Loading branch information
Showing
40 changed files
with
570 additions
and
196 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
3 changes: 3 additions & 0 deletions
3
app/websocket/src/main/kotlin/com/xorker/draw/websocket/EmptyObject.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.xorker.draw.websocket | ||
|
||
object EmptyObject |
This file contains 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
This file contains 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
30 changes: 25 additions & 5 deletions
30
app/websocket/src/main/kotlin/com/xorker/draw/websocket/broker/WebSocketBroadcaster.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
package com.xorker.draw.websocket.broker | ||
|
||
import com.xorker.draw.room.RoomId | ||
import com.xorker.draw.user.UserId | ||
import com.xorker.draw.websocket.BranchedBroadcastEvent | ||
import com.xorker.draw.websocket.BroadcastEvent | ||
import com.xorker.draw.websocket.RespectiveBroadcastEvent | ||
import com.xorker.draw.websocket.SessionMessage | ||
import com.xorker.draw.websocket.UnicastEvent | ||
import org.springframework.context.ApplicationEventPublisher | ||
import org.springframework.stereotype.Component | ||
|
||
interface WebSocketBroadcaster { | ||
fun unicast(userId: UserId, message: SessionMessage) | ||
fun broadcast(roomId: RoomId, sessionMessage: SessionMessage) | ||
fun publishBroadcastEvent(event: BroadcastEvent) | ||
fun publishBranchedBroadcastEvent(event: BranchedBroadcastEvent) | ||
fun publishRespectiveBroadcastEvent(event: RespectiveBroadcastEvent) | ||
} | ||
|
||
@Component | ||
class WebSocketBroadcaster( | ||
internal class WebSocketBroadcasterSingleInstance( | ||
private val publisher: ApplicationEventPublisher, | ||
) { | ||
fun publishBroadcastEvent(event: BroadcastEvent) { | ||
) : WebSocketBroadcaster { | ||
override fun unicast(userId: UserId, message: SessionMessage) { | ||
publisher.publishEvent(UnicastEvent(userId, message)) | ||
} | ||
|
||
override fun broadcast(roomId: RoomId, sessionMessage: SessionMessage) { | ||
publisher.publishEvent(BroadcastEvent(roomId, sessionMessage)) | ||
} | ||
|
||
override fun publishBroadcastEvent(event: BroadcastEvent) { | ||
publisher.publishEvent(event) | ||
} | ||
|
||
fun publishBranchedBroadcastEvent(event: BranchedBroadcastEvent) { | ||
override fun publishBranchedBroadcastEvent(event: BranchedBroadcastEvent) { | ||
publisher.publishEvent(event) | ||
} | ||
|
||
fun publishRespectiveBroadcastEvent(event: RespectiveBroadcastEvent) { | ||
override fun publishRespectiveBroadcastEvent(event: RespectiveBroadcastEvent) { | ||
publisher.publishEvent(event) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ enum class RequestAction( | |
INIT("세션 초기화"), | ||
START_GAME("마피아 게임 시작"), | ||
DRAW("그림 그리기"), | ||
END_TURN("턴 넘기기"), | ||
} |
This file contains 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
Oops, something went wrong.