Android SDK API Reference

Public Member Functions | List of all members
io.skyway.Peer.SFURoom Class Reference

SFU room class. More...

Inheritance diagram for io.skyway.Peer.SFURoom:
io.skyway.Peer.Room

Public Member Functions

void close ()
 Close PeerConnection and emit leave and close event.
 
void replaceStream (MediaStream stream)
 Change the MediaStream that is being sent. More...
 
boolean send (Object data) throws IllegalArgumentException
 Send data to all participants in the room with WebSocket. More...
 
void on (RoomEventEnum event, OnCallback callback) throws IllegalArgumentException
 Set blocks for Room events. More...
 
void getLog ()
 Send data to all participants in the room with WebSocket. More...
 
String getRoomName ()
 Get room name. More...
 
void finalize ()
 
Peer getProvider ()
 Get the peer object that generated this room. More...
 

Detailed Description

SFU room class.

Class that manages SFU type room.

Member Function Documentation

◆ getLog()

void io.skyway.Peer.Room.getLog ( )
inherited

Send data to all participants in the room with WebSocket.

The result is returned in the LOG event.

Room room;
room.on(Room.RoomEventEnum.LOG, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String[])) return;
String[] logs = (String[])object;
for (String log : logs) {
try {
JSONObject jsonLog = new JSONObject(log);
}
catch (JSONException e) { }
}
}
});

◆ getProvider()

Peer io.skyway.Peer.Room.getProvider ( )
inherited

Get the peer object that generated this room.

Returns
Peer object

◆ getRoomName()

String io.skyway.Peer.Room.getRoomName ( )
inherited

Get room name.

Returns
name of this room

◆ on()

void io.skyway.Peer.Room.on ( RoomEventEnum  event,
OnCallback  callback 
) throws IllegalArgumentException
inherited

Set blocks for Room events.

Room room;
room.on(Room.RoomEventEnum.OPEN, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String)) return;
String roomName = (String)object;
}
});
room.on(Room.RoomEventEnum.CLOSE, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String)) return;
String roomName = (String)object;
}
});
room.on(Room.RoomEventEnum.ERROR, new OnCallback() {
@Override
public void onCallback(Object object) {
}
});
room.on(Room.RoomEventEnum.PEER_JOIN, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String)) return;
String peerId = (String)object;
}
});
room.on(Room.RoomEventEnum.PEER_LEAVE, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String)) return;
String peerId = (String)object;
}
});
room.on(Room.RoomEventEnum.DATA, new OnCallback2() {
@Override
public void onCallback(Object object) { }
@Override
public void onCallback(final Object object1, final Object object2) {
String peerId = (String)object1;
if (object2 instanceof String) {
String message = (String)object2;
}
else if (object2 instanceof byte[]) {
byte[] array = (byte[])object2;
}
}
});
room.on(Room.RoomEventEnum.LOG, new OnCallback() {
@Override
public void onCallback(Object object) {
if (!(object instanceof String[])) return;
String[] logs = (String[])object;
}
});
Parameters
eventEvent type
callbackCallback block literal
Exceptions
IllegalArgumentException\ a callback is not \ a OnCallback2

◆ replaceStream()

void io.skyway.Peer.SFURoom.replaceStream ( MediaStream  stream)

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".

SFURoom room;
MediaStream stream;
room.replaceStream(stream);
Parameters
streamThe stream to replace the old stream with.

◆ send()

boolean io.skyway.Peer.Room.send ( Object  data) throws IllegalArgumentException
inherited

Send data to all participants in the room with WebSocket.

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.

Parameters
dataSend data
Returns
Result
Exceptions
IllegalArgumentException