Android SDK API Reference

Classes | Public Member Functions | List of all members
io.skyway.Peer.Room Class Referenceabstract

Room base class. More...

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

Classes

enum  RoomEventEnum
 Room event enumerator. More...
 

Public Member Functions

abstract void close ()
 Close PeerConnection and emit leave and close event.
 
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

Room base class.

Member Function Documentation

◆ getLog()

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

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 ( )

Get the peer object that generated this room.

Returns
Peer object

◆ getRoomName()

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

Get room name.

Returns
name of this room

◆ on()

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

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

◆ send()

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

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