Skip to content

lepicekmichal/SignalRKore

Repository files navigation

SignalRKore

Maven Central Kotlin GitHub License Kotlin Weekly

badge-android badge-jvm badge-ios

Overview

SignalRKore is a Kotlin Multiplatform client library for ASP.NET Core SignalR. It enables real-time communication between clients and servers, allowing server-side code to push content to clients and vice-versa instantly.

Why should you use this library

Official client library SignalRKore
Written in Java Kotlin
KMM / KMP ✖️ Android, JVM, iOS
Network OkHttp only Ktor
Async RxJava Coroutines
Serialization Gson (non-customizable) Kotlinx Serializable (customizable)
Streams ✔️ ✔️
Transport fallback ✖️ ✖️
Automatic reconnect ✖️ ✔️
SSE ✖️ ✔️
Connection status ✖️ ✔️
Logging SLF4J Custom interface
MsgPack ✔️ ✖️
Tested by time & community ✔️ ✖️

Quick Example

// Create a connection
val connection = HubConnectionBuilder.create("http://localhost:5000/chat")

// Start the connection
connection.start()

// Send a message to the server
connection.send("broadcastMessage", "User", "Hello, SignalR!")

// Receive messages from the server
connection.on("broadcastMessage", String::class, String::class).collect { (user, message) ->
    println("$user says: $message")
}

// Don't forget to stop the connection when done
connection.stop()

How to use

Please see the documentation.

Acknowledgments

All functionality was possible to implement only thanks to AzureSignalR ChatRoomLocal sample.

License

SignalRKore is released under the Apache 2.0 license.

TODO list

  • Readme
  • Documentation
  • Add example project
  • Fix up ServerSentEvents' http client
  • Add logging
  • Error handling
  • Add tests
  • Implement streams
  • Extend to JVM
  • Extend to iOS
  • Implement transport fallback
  • Implement automatic reconnect
  • Reacting to stream invocation from server