SDK
SDK Jvm v1.x
2

count #

Returns the number of other connections sharing the same subscription.

:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
public CompletableFuture<Integer> count(String roomId)
  throws NotConnectedException, InternalException
Argument Type Description
roomId
String
Subscription room ID

Return #

Returns the number of active connections using the same provided subscription room.

Usage #

Copied to clipboard!
Map<String, Object> filters = new HashMap<>();
filters.put("exists", "name");
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();
final Integer result = kuzzle.getRealtimeController().count(roomId).get();

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun count(roomId: String): CompletableFuture<Int>
Argument Type Description
roomId
String
Subscription room ID

Return #

Returns the number of active connections using the same provided subscription room.

Usage #

Copied to clipboard!
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 result: Int = kuzzle.realtimeController.count(roomId).get()

::: ::::