Join Room

Joining a room is one of the most basic functionalities so we at 100ms have built an easy, developer friendly API to get you started.

A user can interact with participants of a room only after joining the room.

When user indicates that they want to join the room, your app should have -

  1. userName, the name which should be displayed to other peers in the room
  2. userID, a unique identifier for the user. It can be your reference identifier or a UUID string.
  3. roomID, the unique room identifier which would have been generated & passed to your app from backend
  4. authToken, the client side authentication token generated by your Token Service

Now that you have aforementioned data, you can proceed to join a room.

  1. First, create an instance of HMSSDK class. Store this instance as a property. Ensure that the SDK object is alive in memory so that you can receive event callbacks from SDK. Simplest way to do this is as follows -
import HMSSDK class MyMeetingClass { let hmsSDK: HMSSDK // store instance of HMSSDK as a property in your class init() { hmsSDK = // initialize the SDK using the `build()` class function } }

Note: If you are using Preview then you must already have an instance of HMSSDK before invoking Preview APIs.

  1. Next, create an object of HMSConfig class using the available joining configurations
let config = HMSConfig(userName: "My good name", userID: UUID().uuidString, roomID: "abc123", authToken: "eyJH5c")
  1. Now, we are primed to join the room. All you have to do is pass the config object to hmsSDK
hmsSDK.join(config: config, delegate: self)

That's it. You have joined a room successfully. 🥳

Now, let's take a look at the signature of the Join API

func join(config: HMSConfig, delegate: HMSUpdateListener)

As evident, join accepts 2 arguments -

  • config: an object of type HMSConfig class, the room configuration object which encapsulates user & token data
  • delegate: a class conforming to HMSUpdateListener protocol.

The methods of HMSUpdateListener are invoked to notify updates happening in the room like a peer joins/leaves, a track got muted/unmutes, etc.

After calling join your app will be provided an update from the 100ms SDK.

If successful, the func on(join room: HMSRoom) method of HMSUpdateListener will be invoked with information about the room encapsulated in the HMSRoom object.

If failure, the func on(error: HMSError) method will be invoked with exact failure reason.