-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor/socket io event refactor (#195)
* ♻️ 重構 WebSocketEvent * 🐛 修正 Broadcast 行為 * fix: socket io event mapping --------- Co-authored-by: KuoChe <[email protected]>
- Loading branch information
1 parent
8a0948c
commit 02a647d
Showing
13 changed files
with
99 additions
and
99 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
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
15 changes: 10 additions & 5 deletions
15
domain/src/main/kotlin/tw/waterballsa/gaas/events/EndedGameEvent.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,12 +1,17 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.domain.Room | ||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
data class EndedGameEvent( | ||
val type: EventMessageType, | ||
val data: Data, | ||
) : DomainEvent() { | ||
class EndedGameEvent( | ||
type: EventMessageType, | ||
val data: Data | ||
) : RoomEvent(type) { | ||
data class Data( | ||
val roomId: String, | ||
val roomId: Room.Id, | ||
) | ||
|
||
override fun getEventData(): Any = data | ||
|
||
override fun getRoomId(): Room.Id = data.roomId | ||
} |
15 changes: 10 additions & 5 deletions
15
domain/src/main/kotlin/tw/waterballsa/gaas/events/PlayerJoinedRoomEvent.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,18 +1,23 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.domain.Room | ||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
data class PlayerJoinedRoomEvent( | ||
val type: EventMessageType, | ||
val data: Data, | ||
) : DomainEvent() { | ||
class PlayerJoinedRoomEvent( | ||
type: EventMessageType, | ||
val data: Data | ||
) : RoomEvent(type) { | ||
data class Data( | ||
val user: Player, | ||
val roomId: String, | ||
val roomId: Room.Id, | ||
) { | ||
data class Player( | ||
val id: String, | ||
val nickname: String, | ||
) | ||
} | ||
|
||
override fun getEventData(): Any = data | ||
|
||
override fun getRoomId(): Room.Id = data.roomId | ||
} |
15 changes: 10 additions & 5 deletions
15
domain/src/main/kotlin/tw/waterballsa/gaas/events/PlayerLeavedRoomEvent.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,18 +1,23 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.domain.Room | ||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
data class PlayerLeavedRoomEvent( | ||
val type: EventMessageType, | ||
val data: Data, | ||
) : DomainEvent() { | ||
class PlayerLeavedRoomEvent( | ||
type: EventMessageType, | ||
val data: Data | ||
) : RoomEvent(type) { | ||
data class Data( | ||
val user: Player, | ||
val roomId: String, | ||
val roomId: Room.Id, | ||
) { | ||
data class Player( | ||
val id: String, | ||
val nickname: String, | ||
) | ||
} | ||
|
||
override fun getEventData(): Any = data | ||
|
||
override fun getRoomId(): Room.Id = data.roomId | ||
} |
15 changes: 10 additions & 5 deletions
15
domain/src/main/kotlin/tw/waterballsa/gaas/events/PlayerReadinessChangedEvent.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,18 +1,23 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.domain.Room | ||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
data class PlayerReadinessChangedEvent( | ||
val type: EventMessageType, | ||
val data: Data, | ||
) : DomainEvent() { | ||
class PlayerReadinessChangedEvent( | ||
type: EventMessageType, | ||
val data: Data | ||
) : RoomEvent(type) { | ||
data class Data( | ||
val user: User, | ||
val roomId: String, | ||
val roomId: Room.Id, | ||
) { | ||
data class User( | ||
val id: String, | ||
val nickname: String, | ||
) | ||
} | ||
|
||
override fun getEventData(): Any = data | ||
|
||
override fun getRoomId(): Room.Id = data.roomId | ||
} |
8 changes: 8 additions & 0 deletions
8
domain/src/main/kotlin/tw/waterballsa/gaas/events/RoomEvent.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,8 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.domain.Room | ||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
abstract class RoomEvent(type: EventMessageType) : SocketIOResponseEvent(type) { | ||
abstract fun getRoomId(): Room.Id | ||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/tw/waterballsa/gaas/events/SocketIOResponseEvent.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,7 @@ | ||
package tw.waterballsa.gaas.events | ||
|
||
import tw.waterballsa.gaas.events.enums.EventMessageType | ||
|
||
abstract class SocketIOResponseEvent(val type: EventMessageType) : DomainEvent() { | ||
abstract fun getEventData(): Any | ||
} |
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
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