io.agora.rtm.PresenceEvent Maven / Gradle / Ivy
package io.agora.rtm;
import io.agora.common.internal.CalledByNative;
import io.agora.rtm.IntervalInfo;
import io.agora.rtm.RtmConstants.RtmChannelType;
import io.agora.rtm.RtmConstants.RtmPresenceEventType;
import io.agora.rtm.SnapshotInfo;
import io.agora.rtm.TopicInfo;
import java.util.ArrayList;
import java.util.Arrays;
public class PresenceEvent {
/**
* Indicate presence event type
*/
private RtmPresenceEventType eventType;
/**
* Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE
*/
private RtmChannelType channelType;
/**
* The channel which the presence event was triggered
*/
private String channelName = "";
/**
* The user who triggered this event.
*/
private String publisher = "";
/**
* The user states.
*/
private ArrayList stateItems;
/**
* Only valid when in interval mode
*/
private IntervalInfo interval;
/**
* Only valid when receive snapshot event
*/
private SnapshotInfo snapshot;
/**
* Creates a new instance of {@code PresenceEvent} with default parameters.
*/
public PresenceEvent() {
this.eventType = RtmPresenceEventType.NONE;
this.channelType = RtmChannelType.NONE;
this.stateItems = new ArrayList();
this.interval = new IntervalInfo();
this.snapshot = new SnapshotInfo();
}
@CalledByNative
public PresenceEvent(int eventType, int channelType, String channelName, String publisher,
StateItem[] stateItems, IntervalInfo interval, SnapshotInfo snapshot) {
this.eventType = RtmPresenceEventType.getEnum(eventType);
this.channelType = RtmChannelType.getEnum(channelType);
this.channelName = channelName;
this.publisher = publisher;
this.stateItems = new ArrayList(Arrays.asList(stateItems));
this.interval = interval;
this.snapshot = snapshot;
}
public RtmPresenceEventType getEventType() {
return this.eventType;
}
public RtmChannelType getChannelType() {
return this.channelType;
}
public String getChannelName() {
return this.channelName;
}
public String getPublisherId() {
return this.publisher;
}
public ArrayList getStateItems() {
return this.stateItems;
}
public IntervalInfo getInterval() {
return this.interval;
}
public SnapshotInfo getSnapshot() {
return this.snapshot;
}
@Override
public String toString() {
return "PresenceEvent {eventType: " + eventType + ", channelType: " + channelType
+ ", channelName: " + channelName + ", publisher: " + publisher + ", stateItems: "
+ stateItems + ", interval: " + interval + ", snapshot: " + snapshot + "}";
}
}