SDK
SDK Jvm v1.x
2

unsubscribe #

Removes a subscription.

:::: tabs ::: tab Java

Arguments #

public CompletableFuture<Void> unsubscribe(final String roomId) 
  throws NotConnectedException, InternalException
ArgumentTypeDescription
roomId
String
Subscription room ID

Usage #

Map<String, Object> filters = new HashMap<>();
filters.put("exists", "name");
Map<String, Object> document = new HashMap<>();
document.put("name", "nina-vkote");
final String roomId = kuzzle.getRealtimeController().subscribe(
  "nyc-open-data",
  "yellow-taxi",
  filters,
  notification -> {
    if (notification.getScope().equals("in")) {
      System.out.println("Document entered the scope");
    } else {
      System.out.println("Document left the scope");
    }
}).get();
kuzzle.getRealtimeController().unsubscribe(roomId).get();

::: ::: tab Kotlin

Arguments #

fun unsubscribe(roomId: String): CompletableFuture<Void>
ArgumentTypeDescription
roomId
String
Subscription room ID

Usage #

val filters: Map<String, Any> = HashMap<String, Any>().apply {
  put("exists", "name")
}
val roomId: String = kuzzle.realtimeController.subscribe(
    "nyc-open-data",
    "yellow-taxi",
    filters) {
  if (it.scope == "in") {
    println("Document entered the scope")
  } else {
    println("Document left the scope")
  }
}.get()
val document: Map<String, Any> = HashMap<String, Any>().apply {
  put("name", "nina-vkote")
}
kuzzle.realtimeController.unsubscribe(roomId)

::: ::::