Simple kotlin client wrapper for creating and managing rooms on cosmobuzz.net. Created as a sub-project of a trivia controller for trivia nights with my friends.
Creating a room:
when (val result = CosmoBuzz.createRoom()) {
is CreateRoomResult.Success -> run(result.room)
is CreateRoomResult.Failure -> error(result.reason)
}
CosmoBuzzRoom
is essentially a view-model for a room's state
Accessing state:
room.players.collect { players -> playersChanged(players) }
room.settings.collect { settings -> settingsChanged(settings) }
room.buzzer.collect { player -> playerBuzzed(player) }
Updating room:
room.resetBuzzers()
room.updateSettings(newRoomSettings)
The examples project contains a (basic) cli interpreter around a CosmoBuzzRoom
, here is an example run:
CosmoBuzzRoom(code=427126, url=https://www.cosmobuzz.net/#/play/<room-code>)
>list-players
Players (2):
PlayerA
PlayerB
BUZZ: PlayerA
BUZZ: PlayerB
>reset-buzzers
>toggle-first-buz
BUZZ: PlayerA
Add a gradle dependency to your project:
Groovy
repositories {
mavenCentral()
}
implementation "com.tfowl.cosmobuzz:cosmobuzz-client-kotlin:$version"
Kotlin DSL
repositories {
mavenCentral()
}
implementation("com.tfowl.cosmobuzz:cosmobuzz-client-kotlin:$version")
Add a maven dependency to your project:
<dependency>
<groupId>com.tfowl.cosmobuzz</groupId>
<artifactId>cosmobuzz-client-kotlin</artifactId>
<version>${version}</version>
</dependency>
MIT License
Copyright (c) 2021 Thomas Fowler
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.