https://github.com/t-fowl/cosmobuzz-client-kotlin
A [unofficial] simple kotlin client for creating and managing a room on cosmobuzz.net
https://github.com/t-fowl/cosmobuzz-client-kotlin
coroutines cosmobuzz kotlin sharedflow socket-io stateflow trivia trivia-game
Last synced: 3 months ago
JSON representation
A [unofficial] simple kotlin client for creating and managing a room on cosmobuzz.net
- Host: GitHub
- URL: https://github.com/t-fowl/cosmobuzz-client-kotlin
- Owner: T-Fowl
- License: mit
- Created: 2021-09-07T09:37:24.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-09T14:35:08.000Z (about 2 years ago)
- Last Synced: 2025-03-03T03:44:00.792Z (3 months ago)
- Topics: coroutines, cosmobuzz, kotlin, sharedflow, socket-io, stateflow, trivia, trivia-game
- Language: Kotlin
- Homepage:
- Size: 105 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cosmobuzz-client-kotlin (Unofficial)


Simple kotlin client wrapper for creating and managing rooms on [cosmobuzz.net](https://www.cosmobuzz.net/). Created as
a sub-project of a trivia controller for trivia nights with my friends.## Usage
Creating a room:
```kotlin
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:
```kotlin
room.players.collect { players -> playersChanged(players) }
room.settings.collect { settings -> settingsChanged(settings) }
room.buzzer.collect { player -> playerBuzzed(player) }
```Updating room:
```kotlin
room.resetBuzzers()
room.updateSettings(newRoomSettings)
```## Example project
The examples project contains a (basic) cli interpreter around a `CosmoBuzzRoom`, here is an example run:
```shell
CosmoBuzzRoom(code=427126, url=https://www.cosmobuzz.net/#/play/)>list-players
Players (2):
PlayerA
PlayerB
BUZZ: PlayerA
BUZZ: PlayerB>reset-buzzers
>toggle-first-buzBUZZ: PlayerA
```## Download
Add a gradle dependency to your project:
Groovy
```groovy
repositories {
mavenCentral()
}
implementation "com.tfowl.cosmobuzz:cosmobuzz-client-kotlin:$version"
```Kotlin DSL
```kotlin
repositories {
mavenCentral()
}
implementation("com.tfowl.cosmobuzz:cosmobuzz-client-kotlin:$version")
```Add a maven dependency to your project:
```xml
com.tfowl.cosmobuzz
cosmobuzz-client-kotlin
${version}```
## License
```
MIT LicenseCopyright (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.
```