100ms Logo



Search docs

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. User Name, the name which should be displayed to other peers in the room
  2. User ID, a unique identifier for the user. Usually a UUID string.
  3. Room ID, the unique room identifier which would have been generated & passed to your app from the backend.
  4. Authentication Token, 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 -
private val hmsSDK = HMSSDK .Builder(application) .build()

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
val hmsConfig = HMSConfig("user display name", authToken)
  1. You'll want to handle the callbacks from joining the room by making your ViewModel, Presenter or whatever you're using to handle business logic implement the HMSUpdateListener interface and overriding the methods.

  2. Now, we are primed to join the room. All you have to do is pass the config object to hmsSDK

fun joinRoom(config : HMSConfig, hmsUpdateListener : HMSUpdateListener){ hmsSDK.join(config, hmsUpdateListener) }

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

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

fun join(config: HMSConfig, hmsUpdateListener: HMSUpdateListener)

As evident, join accepts 2 arguments -

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

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 fun onJoin(room: HMSRoom) method of HMSUpdateListener will be invoked with information about the room encapsulated in the HMSRoom object.

If failure, the fun onError(error: HMSException) method will be invoked with exact failure reason.