Persistent Participant States (Peer Metadata)

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

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 0.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 change(metadata:completion:) on their HMSSSDK instance.

The data may be any arbitrary string.

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 on(peer: HMSPeer, update: HMSPeerUpdate) of HMSUpdateListener where the update value will be of type HMSPeerUpdate.metadataUpdated.

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.

let newMetadata = "{\"ms\": 100 }" hmsSdk.change(metadata: newMetadata) { success, error in ... }

Have a suggestion? Recommend changes ->

Was this helpful?

1234