An open API service indexing awesome lists of open source software.

https://github.com/incetarik/signalk

SignalK is a wrapper library for Java client library of ASP.NET SignalR
https://github.com/incetarik/signalk

Last synced: 7 months ago
JSON representation

SignalK is a wrapper library for Java client library of ASP.NET SignalR

Awesome Lists containing this project

README

          

# SignalK - A wrapper library for ASP.NET SignalR

SignalK is a wrapper library for Java client library of ASP.NET SignalR, for Kotlin.
This library contains some extension functions to enable developers type less. Also contains
builder functions.

### Examples:
With default Java library when writing in Kotlin
```kotlin
val connection = HubConnection("")
val proxy = connection.createHubProxy("proxy")

proxy.on("event", SubscriptionHandler1 {
println(it)
}, String::class.java)

proxy.on("second-event", { first, second ->
println("Pair: ${first to second}")
proxy.setState("JSON-State", JsonObject())

val state = proxy.getState("JSON-State")
val obj = state.asJsonObject

val subscription = proxy.subscribe("subscribe-event")
subscription.addReceivedHandler { println("Receive handler: $it") }
}, String::class.java, String::class.java)

proxy.on("third-event", { first, second, third ->

})
```

After this small library used
```kotlin
val connection = HubConnection("")

// Direct usage
(HubConnection("")) {
// ...
}

// or with assigned value
connection {
createHubProxy("proxy") {
on("event") { it: String? ->
println(it)
}

on("second-event") { first, second ->
println("Pair: ${first to second}")
this["JSON-State"] = JsonObject()

val state = this["JSON-State"]
val obj = state?.asJsonObject

handle("subscribe-event") {
println("Receive handler: $it")
}
}

on("third-event") { first: String?, second: Int?, third: Boolean? ->

}

// Or

on("third-event") { first, second, third ->

}
}
}
```