100ms Logo

100ms

Docs

Search docs
/

End Room

Done with talking and it's time to end the call for everyone not just yourself? You may be looking to end the room.

Permissions

Can't let just anyone end a call. First you need to create a role with the permissions to end a room.

The permission to end a room is called endRoom and you should check for that within the permissions property of HMSRole of the peer to see if they have it.

Ending the Room

Once you're sure the peer has the permissions to end the room they can call for the room to end when they're ready with hmsSdk.endRoom.

endRoom takes three parameters.

reason: Optional message you want to pass along the end room notification to other peers

lock: Whether you want to prevent anyone from rejoining the room. If false, they will be allowed to enter the room again if the client called join. If this is false, they will not able to join this room again.

completion handler: Lets you know whether the end room operation executed. was ended successfully or not.

💡 After calling endRoom the local peer needs to dispose of the video calling UI as well.

hmssdk.endRoom(lock: false, reason: "Meeting is over") { success, error in if (success) { // pop to previous screen } }

How to handle an end room callback

Once the peer with adequate permissions calls endRoom, all other peers in the room will receive a callback in HMSUpdateListener.onRemovedFromRoom.

The on(removedFromRoom:) callback has a single parameter called HMSRemovedFromRoomNotification with the following structure.

class HMSRemovedFromRoomNotification { public let requestedBy: HMSPeer public let reason: String public let roomEnded: Bool }

💡 This is the same callback that will be triggered if a peer was removed from a room as well. Except that roomEnded will be true when the entire room was ended.

reason: The string message detailing why the room was ended.

requestedBy: The details of the peer who called endRoom.

roomEnded: True if the entire room was ended. False if only the receiving peer was removed.

Clients should read this callback and show the appropriate UI.