Skip to content

Commit eda5d0e

Browse files
committed
Add reified method for addHandler.
1 parent b9a3c85 commit eda5d0e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/main/java/in/dragonbra/javasteam/steam/steamclient/SteamClient.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ class SteamClient @JvmOverloads constructor(
109109
addHandlerCore(handler)
110110
}
111111

112+
/**
113+
* Kotlin Helper:
114+
* Adds a new handler to the internal list of message handlers.
115+
* @param T The handler to add.
116+
*/
117+
inline fun <reified T : ClientMsgHandler> addHandler() {
118+
val handler = T::class.java.getDeclaredConstructor().newInstance()
119+
addHandler(handler)
120+
}
121+
112122
private fun addHandlerCore(handler: ClientMsgHandler) {
113123
handler.setup(this)
114124
handlers[handler.javaClass] = handler

0 commit comments

Comments
 (0)