Single-step configuration based API for setting up a room - a solution for all your other streaming applications including Group Broadcast, Group Chat, and One to One Chat. The Room Express extends the lower-level Room Service API to provide easy solutions to:
Join a room and optionally, automatically subscribe to member changes.
Swift
importPhenixSdklet roomExpress: PhenixRoomExpress = ... // previously obtainedlet joinRoomOptions = PhenixRoomExpressFactory.createJoinRoomOptionsBuilder() .withRoomAlias("myRoom42") .buildJoinRoomOptions()roomExpress.joinRoom(joinRoomOptions, { (status: PhenixRequestStatus, roomService: PhenixRoomService?) inif status == .ok {// Hold on to roomService reference for as long as you wish to stay in the room } else {// Handle error } })// With optional member update notification:roomExpress.joinRoom( joinRoomOptions, { (status: PhenixRequestStatus, roomService: PhenixRoomService?) inif status == .ok {// Hold on to roomService reference for as long as you wish to stay in the room } else {// Handle error } }, { (members: [PhenixMember]?) in// Do something with room members })
Express Join Room Parameters
Name
Type
Description
options (required)
PhenixJoinRoomOptions
Options to join room with
joinRoomCallback (required)
Function
Function to call on success/failure of joining the room
membersChangedCallback (optional)
Function
Function to call on when the participant members in the room changes. Returns array of Members. Callback is guaranteed to be called at least once when room is joined.
Subscribe to a room member's stream and automatically handle audio and video state changes.
Swift
importPhenixSdklet roomExpress: PhenixRoomExpress = ... // previously obtainedlet room: PhenixImmutableRoom = ... // previously obtainedlet renderLayer: CALayer = ... // previously obtained// Just an example showing how to get a stream from a member.// In a real-world app you would want to subscribe to the room-members-observable on the room// to receive updates when the list of members changes, and then subscribe to the streams-observable// on each member to access their streams.let member = room.getObservableMembers().getValue()[0] as! PhenixMemberlet memberStream = member.getObservableStreams().getValue[0] as! PhenixStreamlet options = PhenixRoomExpressFactory.createSubscribeToMemberStreamOptionsBuilder() .withStreamToken("DIGEST:eyJhc...") .withRenderer(renderLayer) .buildSubscribeToMemberStreamOptions()roomExpress.subscribe(toMemberStream: memberStream, options, { [weakself] (status: PhenixRequestStatus,subscriber: PhenixExpressSubscriber?,renderer: PhenixRenderer?) inguard status == .ok, let strongSelf = selfelse {// Handle subscribe errorreturn }// Important: Store subscriber reference, otherwise we will stop subscription immediately: strongSelf.currentSubscriber = subscriber })
Optional renderer if renderer was enabled, else nil
Publish to a Room
Publish local media to a room. An error will be returned if a room corresponding to the Room Options passed does not exist. If you have not entered the room via joinRoom or publishToRoom methods then a model for Self will be created.
Underlying resources are kept alive for as long as you hold any references to any of the returned objects (room service, subscriber, renderer). Once those references as well as any reference to the room express instance itself have been released, all underlying resources will be automatically cleaned up and released.