NBMRoomClient Class Reference
Inherits from | NSObject |
---|---|
Declared in | NBMRoomClient.h |
Overview
It’s actually only a wrapper over the JSON-RPC protocol used to communicate with Room Server. The developer of room applications can use this API when implementing an iOS client.
delegate
The delegate object for the client.
@property (nonatomic, weak) id<NBMRoomClientDelegate> delegate
Declared In
NBMRoomClient.h
peers
A list of connected NBMPeer objects.
@property (nonatomic, readonly) NSArray *peers
Declared In
NBMRoomClient.h
room
The NBMRoom instance representing the joined room.
@property (nonatomic, readonly) NBMRoom *room
Declared In
NBMRoomClient.h
timeout
The timeout interval for API requests, in seconds. Default value is 5.
@property (nonatomic, assign, readonly) NSTimeInterval timeout
Declared In
NBMRoomClient.h
connectionState
@property (nonatomic, assign, readonly) NBMRoomClientConnectionState connectionState
connected
A Boolean that indicates the WebSocket connection status.
@property (nonatomic, assign, readonly, getter=isConnected) BOOL connected
Declared In
NBMRoomClient.h
joined
A Boolean that indicates if the room was joined by the local peer.
@property (nonatomic, assign, readonly, getter=isJoined) BOOL joined
Declared In
NBMRoomClient.h
– initWithRoom:delegate:
Creates and initializes a NBMRoomClient with default API timeout interval.
- (instancetype)initWithRoom:(NBMRoom *)room delegate:(id<NBMRoomClientDelegate>)delegate
Parameters
room |
The room to join with. |
---|---|
delegate |
The delegate object for the client |
Return Value
An initialized NBMRoomClient object.
Declared In
NBMRoomClient.h
– initWithRoom:timeout:delegate:
Creates and initializes a NBMRoomClient with a custom API timeout interval.
- (instancetype)initWithRoom:(NBMRoom *)room timeout:(NSTimeInterval)timeout delegate:(id<NBMRoomClientDelegate>)delegate
Parameters
room |
The room to join with. |
---|---|
timeout |
The timeout interval for API requests, in seconds. |
delegate |
The delegate object for the client. |
Return Value
An initialized NBMRoomClient object.
Declared In
NBMRoomClient.h
– connect
Connects client to the Room Server using WebSocket, giving access to its API when the connection is established successfully.
- (void)connect
Discussion
Note: See [NBMRoomClientDelegate client:isConnected:] method.
Declared In
NBMRoomClient.h
– joinRoom
Represents a client’s request to join a room. If the room does not exists, it is created. When the request is processed, the [NBMRoomClientDelegate client:didJoinRoom:] message is sent to the client’s delegate.
- (void)joinRoom
Declared In
NBMRoomClient.h
– joinRoom:
Represents a client’s request to join a room. If the room does not exists, it is created.
- (void)joinRoom:(void ( ^ ) ( NSSet *peers , NSError *error ))block
Parameters
block |
A block object to be executed when the request is processed. This block has no return value and takes an NSSet of remote participants and an error if the request failed. |
---|
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– leaveRoom
Represent a client’s notification that it’s leaving the room. When the request is processed, the [NBMRoomClientDelegate client:didLeaveRoom:] message is sent to the client’s delegate.
- (void)leaveRoom
Declared In
NBMRoomClient.h
– leaveRoom:
Represent a client’s notification that it’s leaving the room.
- (void)leaveRoom:(void ( ^ ) ( NSError *error ))block
Parameters
block |
A block object to be executed when the request is processed. This block has no return value and takes an error if the request failed. |
---|
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– publishVideo:loopback:
Represents a client’s request to start streaming her local media to anyone inside the room. When the request is processed, the [NBMRoomClientDelegate client:didPublishVideo:loopback:error:] message is sent to the client’s delegate.
- (void)publishVideo:(NSString *)sdpOffer loopback:(BOOL)doLoopback
Parameters
sdpOffer |
A NSString representing an SDP offer. |
---|---|
doLoopback |
A Boolean enabling media loopback. |
Declared In
NBMRoomClient.h
– publishVideo:loopback:completion:
Represents a client’s request to start streaming her local media to anyone inside the room.
- (void)publishVideo:(NSString *)sdpOffer loopback:(BOOL)doLoopback completion:(void ( ^ ) ( NSString *sdpAnswer , NSError *error ))block
Parameters
sdpOffer |
A NSString representing an SDP offer. |
---|---|
doLoopback |
A Boolean enabling media loopback. |
block |
A block object to be executed when the request is processed. This block has no return value and takes the SDP answer sent by KMS and an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– unpublishVideo
Represents a client’s request to stop streaming its local media to the room peers. When the request is processed, the [NBMRoomClientDelegate client:didUnPublishVideo:] message is sent to the client’s delegate.
- (void)unpublishVideo
Declared In
NBMRoomClient.h
– unpublishVideo:
Represents a client’s request to stop streaming its local media to the room peers.
- (void)unpublishVideo:(void ( ^ ) ( NSError *error ))block
Parameters
block |
A block object to be executed when the request is processed. This block has no return value and takes an error if the request failed. |
---|
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– receiveVideoFromPeer:offer:
Represents a client’s request to receive media from participants in the room that published their media. This method can also be used for loopback connections. When the request is processed, the [NBMRoomClientDelegate client:didReceiveVideoFrom:sdpAnswer:error:] message is sent to the client’s delegate.
- (void)receiveVideoFromPeer:(NBMPeer *)peer offer:(NSString *)sdpOffer
Parameters
peer |
A NBMPeer that is publishing media. |
---|---|
sdpOffer |
A NSString representing an SDP offer. |
Declared In
NBMRoomClient.h
– receiveVideoFromPeer:offer:completion:
Represents a client’s request to receive media from participants in the room that published their media.
- (void)receiveVideoFromPeer:(NBMPeer *)peer offer:(NSString *)sdpOffer completion:(void ( ^ ) ( NSString *sdpAnswer , NSError *error ))block
Parameters
peer |
A NBMPeer that is publishing media. |
---|---|
sdpOffer |
A NSString representing an SDP offer. |
block |
A block object to be executed when the request is processed. This block has no return value and takes the SDP answer sent by KMS and an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– unsubscribeVideoFromPeer:
Represents a client’s request to stop receiving media from a given publisher. When the request is processed, the [NBMRoomClientDelegate client:didUnsubscribeVideoFrom:sdpAnswer:error:] message is sent to the client’s delegate.
- (void)unsubscribeVideoFromPeer:(NBMPeer *)peer
Parameters
peer |
A NBMPeer that is publishing media. |
---|
Declared In
NBMRoomClient.h
– unsubscribeVideoFromPeer:completion:
Represents a client’s request to stop receiving media from a given publisher.
- (void)unsubscribeVideoFromPeer:(NBMPeer *)peer completion:(void ( ^ ) ( NSString *sdpAnswer , NSError *error ))block
Parameters
peer |
The NBMPeer that is publishing media. |
---|---|
block |
A block object to be executed when the request is processed. This block has no return value and takes the SDP answer sent by KMS and an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– sendICECandidate:forPeer:
Request that carries info about an ICE candidate gathered on the client side. This information is required to implement the trickle ICE mechanism. When the request is processed, the [NBMRoomClientDelegate client:didUnsubscribeVideoFrom:sdpAnswer:error:] message is sent to the client’s delegate.
- (void)sendICECandidate:(RTCICECandidate *)candidate forPeer:(NBMPeer *)peer
Parameters
candidate |
The RTCICECandidate object to send. |
---|---|
peer |
The NBMPeer whose ICE candidate was found. |
Declared In
NBMRoomClient.h
– sendICECandidate:forPeer:completion:
Request that carries info about an ICE candidate gathered on the client side. This information is required to implement the trickle ICE mechanism.
- (void)sendICECandidate:(RTCICECandidate *)candidate forPeer:(NBMPeer *)peer completion:(void ( ^ ) ( NSError *error ))block
Parameters
candidate |
The RTCICECandidate object to send. |
---|---|
peer |
The NBMPeer whose ICE candidate was found. |
block |
A block object to be executed when the request is processed. This block has no return value and takes an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– sendMessage:
Represents a client’s request to send written message to all other participants in the room. When the request is processed, the [NBMRoomClientDelegate client:didSentMessage:] message is sent to the client’s delegate.
- (void)sendMessage:(NSString *)message
Parameters
message |
The text message. |
---|
Declared In
NBMRoomClient.h
– sendMessage:completion:
Represents a client’s request to send written message to all other participants in the room.
- (void)sendMessage:(NSString *)message completion:(void ( ^ ) ( NSError *error ))block
Parameters
message |
The text message. |
---|---|
block |
A block object to be executed when the request is processed. This block has no return value and takes an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– sendCustomRequest:
Provides a custom envelope for requests not directly implemented by the Room server. When the request is processed, the [NBMRoomClientDelegate client:didSentCustomRequest:] message is sent to the client’s delegate.
- (void)sendCustomRequest:(NSDictionary<NSString*,NSString*> *)params
Parameters
params |
A NSDictionary of NSString key-value parameters, their specification is left to the actual implementation. |
---|
Declared In
NBMRoomClient.h
– sendCustomRequest:completion:
Provides a custom envelope for requests not directly implemented by the Room server.
- (void)sendCustomRequest:(NSDictionary<NSString*,NSString*> *)params completion:(void ( ^ ) ( NSError *error ))block
Parameters
params |
A NSDictionary of NSString key-value parameters, their specification is left to the actual implementation. |
---|---|
block |
A block object to be executed when the request is processed. This block has no return value and takes an error if the request failed. |
Discussion
Note: No message is sent to client’s delegate.
Declared In
NBMRoomClient.h
– peerWithIdentifier:
Returns a remote NBMPeer with specified identifier, if exists.
- (NBMPeer *)peerWithIdentifier:(NSString *)identifier
Parameters
identifier |
A unique NSString identifier (peer’s username). |
---|
Return Value
a NBMPeer object with specified identifier.
Declared In
NBMRoomClient.h