Constructors

/*
 Constructors are not exposed in the JS/Node SDK.
 Room objects are returned by Collection.subscribe and
 Document.subscribe methods.

 You may also use the Collection.room() method:
 */
var room = kuzzle.collection('collection', 'index').room();

room = kuzzle
  .collection('collection', 'index')
  .room({subscribeToSelf: false});
Room room = new Room(dataCollection);

RoomOptions options = new RoomOptions().setSubscribeToSelf(false);
Room room = new Room(dataCollection, options);
<?php

// not implemented (this SDK uses HTTP and is thus stateless)

The Room object is the result of a subscription request, allowing to manipulate the subscription itself.


Room(Collection, [options])

ArgumentsTypeDescription
Collectionobjectan instantiated Kuzzle Collection object
optionsobjectOptional subscription configuration

Options

OptionTypeDescriptionDefault
volatileJSON ObjectAdditional information passed to notifications to other usersnull
scopestringFilter document notifications depending on their scope status. You may receive entering documents (scope: in), leaving documents (scope: out), all documents changes (scope: all) or filter these notifications completely (scope: none). This filter does not affect pub/sub messages or user events.all
statestringFilter document notifications depending on the state of the modifying request. You may receive real-time notifications when a document is about to be changed (state: pending), or be notified when the change has been fully written in the database (state: done), or both (state: all). This filter does not affect pub/sub messages or user events.done
subscribeToSelfboolean(Don't) subscribe to notifications fired as a consequence of our own queriestrue
usersstringFilter user notifications triggered upon a user entering the room (user: in), leaving the room (user: out), or both (user: all). Setting this variable to none prevents receiving these notificationsnone

Properties

Property nameTypeDescriptionget/set
collectionstringThe subscribed data collectionget
filtersJSON objectThe current set of filters of this roomget/set
headersJSON ObjectCommon headers for all sent documents.get/set
volatileJSON ObjectAdditional information passed to notifications to other usersget/set
subscribeToSelfboolean(Don't) subscribe to notifications fired as a consequence of our own queriesget/set
roomIdstringUnique room identifierget

Notes:

  • the headers property is inherited from the provided Collection object and can be overridden
  • updating the volatile property takes effect after renew is called
  • by default, the global Kuzzle volatile properties are sent along with the subscription request. If a volatile option is provided during subscription, it will be merged with the global volatile for the subscription only. In case of conflicts, subscription metadata take priority over the global metadata.