https://github.com/maticnetwork/dagger-kotlin-sdk
Dagger client for Kotlin
https://github.com/maticnetwork/dagger-kotlin-sdk
dagger matic web3
Last synced: about 1 year ago
JSON representation
Dagger client for Kotlin
- Host: GitHub
- URL: https://github.com/maticnetwork/dagger-kotlin-sdk
- Owner: maticnetwork
- License: mit
- Created: 2020-01-17T06:52:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-12T12:10:11.000Z (about 6 years ago)
- Last Synced: 2025-04-19T10:28:13.455Z (about 1 year ago)
- Topics: dagger, matic, web3
- Language: Kotlin
- Homepage:
- Size: 136 KB
- Stars: 4
- Watchers: 32
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dagger Kotlin SDK
Dagger client for Kotlin
#### Installation
Add Jitpack to your project level build.gradle file
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
Add the dependency in your app module's build.gradle file:
[](https://jitpack.io/#maticnetwork/dagger-kotlin-sdk)
```
dependencies {
implementation "com.github.maticnetwork:dagger-kotlin-sdk:latest_version"
}
```
#### Getting Started
```
import network.matic.dagger.exceptions.DaggerException
object Main {
@Throws(DaggerException::class)
@JvmStatic
fun main(args: Array) {
val options = Options()
options.callback = object : Callback {
override fun connectionLost(cause: Throwable?) {
println("Connection lost. Reason: $cause")
}
}
val dagger = Dagger("tcp://ropsten.dagger.matic.network", options)
dagger.start()
dagger.on("latest:block", object : Listener {
override fun callback(topic: String?, data: ByteArray?) {
if (data != null) {
println(String(data))
}
}
})
// Wait and keep listening dagger events
synchronized(dagger) {
while (true) {
try {
Thread.sleep(5000)
println("Connected: ${dagger.isConnected()}, Subscriptions: ${dagger.getAllSubscriptions()}")
} catch (e: InterruptedException) {
e.printStackTrace()
}
}
}
}
}
```