iOS SDK API Reference

Instance Methods | Properties | List of all members
SKWSFURoom Class Reference

SFU room class. More...

#import <SKWSFURoom.h>

Inheritance diagram for SKWSFURoom:
SKWRoom

Instance Methods

(void) - close
 Close PeerConnection and emit leave and close event.
 
(void) - replaceStream:
 Change the MediaStream that is being sent. More...
 
(BOOL) - send:
 Send data to all participants in the room with WebSocket. More...
 
(void) - on:callback:
 Set blocks for SKWRoom events. More...
 
(void) - offAll
 Cancels the set event callback block of SKWRoom. More...
 
(void) - getLog
 Start getting room's logs from signaling server. More...
 

Properties

NSString *__nullable name
 Room name.
 

Detailed Description

SFU room class.

Class that manages SFU type room.

Method Documentation

◆ getLog

- (void) getLog

Start getting room's logs from signaling server.

The result is returned in the SKW_ROOM_EVENT_LOG event.

SKWRoom* room;
[room on:SKW_ROOM_EVENT_LOG callback:^(NSObject* obj) {
NSArray* logs = (NSArray*)obj;
[logs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
NSString* logStr = (NSString*)obj;
NSError* error = nil;
id logData = [NSJSONSerialization JSONObjectWithData:[logStr dataUsingEncoding:NSUTF8StringEncoding]
options:0
error:&error];
if (nil == error)
{
NSLog(@"SKW_ROOM_EVENT_LOG: %@", logData);
}
}];
}];
[room getLog];

◆ offAll

- (void) offAll

Cancels the set event callback block of SKWRoom.

SKWRoom* room;
[room offAll];

◆ on:callback:

- (void) on: (SKWRoomEventEnum event
callback: (SKWRoomEventCallback __nullable)  callback 

Set blocks for SKWRoom events.

SKWRoom* room;
[room on:SKW_ROOM_EVENT_STREAM callback:^(NSObject* obj) {
SKWMediaStream* stream = (SKWMediaStream*)obj;
}];
[room on:SKW_ROOM_EVENT_REMOVE_STREAM callback:^(NSObject* obj) {
SKWMediaStream* stream = (SKWMediaStream*)obj;
}];
[room on:SKW_ROOM_EVENT_OPEN callback:^(NSObject* obj) {
NSString* roomName = (NSString*)obj;
}];
[room on:SKW_ROOM_EVENT_CLOSE callback:^(NSObject* obj) {
NSString* roomName = (NSString*)obj;
}];
[room on:SKW_ROOM_EVENT_PEER_JOIN callback:^(NSObject* obj) {
NSString* peerId = (NSString*)obj;
}];
[room on:SKW_ROOM_EVENT_PEER_LEAVE callback:^(NSObject* obj) {
NSString* peerId = (NSString*)obj;
}];
[room on:SKW_ROOM_EVENT_ERROR callback:^(NSObject* obj) {
SKWPeerError* error = (SKWPeerError*)obj;
}];
[room on:SKW_ROOM_EVENT_DATA callback:^(NSObject* obj) {
SKWRoomDataMessage* msg = (SKWRoomDataMessage*)obj;
NSString* peerId = msg.src;
if ([msg.data isKindOfClass:[NSString class]]) {
NSString* data = (NSString*)msg.data;
}
else if ([msg.data isKindOfClass:[NSData class]]) {
NSData* data = (NSData*)msg.data;
}
}];
[room on:SKW_ROOM_EVENT_LOG callback:^(NSObject* obj) {
NSArray* logs = (NSArray*)obj;
}];
Parameters
eventEvent type
callbackCallback block literal

◆ replaceStream:

- (void) replaceStream: (SKWMediaStream *__nullable)  newStream

Change the MediaStream that is being sent.

For example, you can use it to change the camera device or the image quality.

Note: It is not possible to change the state of a MediaStream from not sending to sending.You cannot change the state of MediaStream from not sending to sending and vice versa.
It is also not possible to interchange "MediaStream with either video or audio only" and "MediaStream with both video and audio".

SKWSFURoom* room;
[room replaceStream:stream];
Parameters
newStreamThe stream to replace the old stream with.

◆ send:

- (BOOL) send: (NSObject *__nonnull)  data

Send data to all participants in the room with WebSocket.

It emits broadcast event. The max size of data that can be sent is 20MB. The frequent of consecutive send is limited to once every 100 msec. Outgoing data that exceeds the sending frequency limit is queued and sent sequentially every 100 msec.

SKWRoom* room;
[room send:@"Hello."];
Parameters
dataSend data
Returns
Result.
-[SKWRoom send:]
BOOL send:(NSObject *__nonnull data)
Send data to all participants in the room with WebSocket.
SKWRoomDataMessage
Data received from peer.
Definition: SKWRoomDataMessage.h:14
SKWPeerError
Error information class.
Definition: SKWPeerError.h:76
-[SKWRoom on:callback:]
void on:callback:(SKWRoomEventEnum event,[callback] SKWRoomEventCallback __nullable callback)
Set blocks for SKWRoom events.
-[SKWRoom offAll]
void offAll()
Cancels the set event callback block of SKWRoom.
-[SKWRoom getLog]
void getLog()
Start getting room's logs from signaling server.
SKWMediaStream
Media stream.
Definition: SKWMediaStream.h:18
SKWRoom
Room base class.
Definition: SKWRoom.h:70
SKWSFURoom
SFU room class.
Definition: SKWSFURoom.h:24
-[SKWSFURoom replaceStream:]
void replaceStream:(SKWMediaStream *__nullable newStream)
Change the MediaStream that is being sent.