Peer Metadata Update

Looking for persistent state that can be set on a peer and updated anytime, for everyone in the room? Peer metadata is it.

Metadata can be set initially in the HMSConfig object that's passed into the join method.

This section will show you how to:

  1. Read Peer Metadata.
  2. Respond to when a remote peer changes its metadata.
  3. How to set a peer's metadata.

The HMSPeer object prior to 2.2.1 contained customerDescription a read-only string whose value wouldn't change throughout a call. This has been replaced with metadata. The value is initially assigned as before but now can be changed by the peer who owns it.

Any peer can change the metadata for themselves. Currently one peer cannot change another peer's metadata.

To change their own metadata value the peer should call changeMetadata on their HMSSdk instance.

The data may be any arbitrary string though it cannot be changed to null.

Reading metadata

To read metadata, read the metadata value on any HMSPeer instance.

Responding to updates

Whenever a remote peer's metadata is updated a callback will be received in onPeerUpdate(update : HMSPeerUpdate, peer : HMSPeer) of HMSUpdateListener where the update value will be of type HMSPeerUpdate.METADATA_CHANGED.

When this callback is received the UI for that peer should be updated as well.

Updating Metadata

Here is how a peer can set their own metadata to a random string. In this case the string is stringified json.

val newMetadata = "{\"ms\": 100 }" hmsSdk.changeMetadata(newMetadata, object : HMSActionResultListener { override fun onSuccess() { } override fun onError(error: HMSException) { } })